mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-07-04 13:47:12 -04:00
coding style fix
This commit is contained in:
parent
4250ba1ed2
commit
67d0cd92f8
1 changed files with 17 additions and 0 deletions
|
@ -11,10 +11,12 @@ local min_inv_size = 4 * 8 -- display and provide at least this many slots
|
|||
|
||||
bones = {}
|
||||
|
||||
|
||||
local function NS(s)
|
||||
return s
|
||||
end
|
||||
|
||||
|
||||
local function is_owner(pos, name)
|
||||
local owner = minetest.get_meta(pos):get_string("owner")
|
||||
if owner == "" or owner == name or minetest.check_player_privs(name, "protection_bypass") then
|
||||
|
@ -23,6 +25,7 @@ local function is_owner(pos, name)
|
|||
return false
|
||||
end
|
||||
|
||||
|
||||
local function appendmulti(tbl,...)
|
||||
for _, v in pairs({...}) do
|
||||
table.insert(tbl, v)
|
||||
|
@ -101,6 +104,7 @@ end
|
|||
local share_bones_time = tonumber(minetest.settings:get("share_bones_time")) or 1200
|
||||
local share_bones_time_early = tonumber(minetest.settings:get("share_bones_time_early")) or share_bones_time / 4
|
||||
|
||||
|
||||
local function find_next_empty(inv,listname,start)
|
||||
while start <= inv:get_size(listname) do
|
||||
if inv:get_stack(listname, start):get_count() == 0 then
|
||||
|
@ -111,6 +115,7 @@ local function find_next_empty(inv,listname,start)
|
|||
return -1
|
||||
end
|
||||
|
||||
|
||||
local function find_next_populated(inv, listname, start)
|
||||
while start <= inv:get_size(listname) do
|
||||
if inv:get_stack(listname, start):get_count() > 0 then
|
||||
|
@ -121,6 +126,7 @@ local function find_next_populated(inv, listname, start)
|
|||
return -1
|
||||
end
|
||||
|
||||
|
||||
-- slot reordering to make sure the first rows of the bone are always populated
|
||||
local function bones_inv_reorder(meta)
|
||||
local next_empty = 1 -- there are no empty slots inside the bones before this
|
||||
|
@ -140,6 +146,7 @@ local function bones_inv_reorder(meta)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
local bones_def = {
|
||||
description = S("Bones"),
|
||||
tiles = {
|
||||
|
@ -255,10 +262,12 @@ local bones_def = {
|
|||
end,
|
||||
}
|
||||
|
||||
|
||||
default.set_inventory_action_loggers(bones_def, "bones")
|
||||
|
||||
minetest.register_node("bones:bones", bones_def)
|
||||
|
||||
|
||||
local function may_replace(pos, player)
|
||||
local node_name = minetest.get_node(pos).name
|
||||
local node_definition = minetest.registered_nodes[node_name]
|
||||
|
@ -294,15 +303,19 @@ local function may_replace(pos, player)
|
|||
return node_definition.buildable_to
|
||||
end
|
||||
|
||||
|
||||
local player_inventory_lists = { "main", "craft" }
|
||||
bones.player_inventory_lists = player_inventory_lists
|
||||
|
||||
|
||||
local collect_items_callbacks = {}
|
||||
|
||||
|
||||
function bones.register_collect_items(func)
|
||||
table.insert(collect_items_callbacks, func)
|
||||
end
|
||||
|
||||
|
||||
bones.register_collect_items(function(player)
|
||||
local items = {}
|
||||
local player_inv = player:get_inventory()
|
||||
|
@ -323,6 +336,7 @@ bones.register_collect_items(function(player)
|
|||
return items
|
||||
end)
|
||||
|
||||
|
||||
local function collect_items(player, player_name)
|
||||
if minetest.is_creative_enabled(player_name) then
|
||||
return {}
|
||||
|
@ -335,6 +349,7 @@ local function collect_items(player, player_name)
|
|||
return items
|
||||
end
|
||||
|
||||
|
||||
-- Try to find the closest space near the player to place bones
|
||||
local function find_bones_pos(player)
|
||||
local rounded_player_pos = vector.round(player:get_pos())
|
||||
|
@ -347,6 +362,7 @@ local function find_bones_pos(player)
|
|||
return bones_pos
|
||||
end
|
||||
|
||||
|
||||
local function place_bones(player, bones_pos, items)
|
||||
local param2 = minetest.dir_to_facedir(player:get_look_dir())
|
||||
minetest.set_node(bones_pos, {name = "bones:bones", param2 = param2})
|
||||
|
@ -388,6 +404,7 @@ local function place_bones(player, bones_pos, items)
|
|||
return leftover_items
|
||||
end
|
||||
|
||||
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local bones_mode = minetest.settings:get("bones_mode") or "bones"
|
||||
if bones_mode ~= "bones" and bones_mode ~= "drop" and bones_mode ~= "keep" then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue