1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-11-16 06:50:18 +01:00

coding style fix

This commit is contained in:
Imre Péntek 2024-03-31 14:03:34 +02:00
parent e62cfaafd4
commit cd8cb78856

View File

@ -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,12 +25,14 @@ local function is_owner(pos, name)
return false
end
local function appendmulti(tbl,...)
for _, v in pairs({...}) do
table.insert(tbl, v)
end
end
local function get_bones_formspec_for_size(numitems)
local cols, rows
local scroll=false
@ -61,9 +65,11 @@ local function get_bones_formspec_for_size(numitems)
return table.concat(output)
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
@ -74,6 +80,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
@ -84,6 +91,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
@ -103,6 +111,7 @@ local function bones_inv_reorder(meta)
end
end
local bones_def = {
description = S("Bones"),
tiles = {
@ -213,10 +222,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]
@ -252,7 +263,8 @@ local function may_replace(pos, player)
return node_definition.buildable_to
end
local drop = function(pos, itemstack)
local function drop(pos, itemstack)
local obj = minetest.add_item(pos, itemstack:take_item(itemstack:get_count()))
if obj then
obj:set_velocity({
@ -263,14 +275,17 @@ local drop = function(pos, itemstack)
end
end
bones.player_inventory_lists = { "main", "craft" }
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()
@ -291,6 +306,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 {}
@ -303,6 +319,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())
@ -315,6 +332,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})
@ -356,6 +374,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