mirror of
https://github.com/minetest/minetest_game.git
synced 2025-01-09 15:00:18 +01:00
coding style fix
This commit is contained in:
parent
e62cfaafd4
commit
cd8cb78856
@ -11,10 +11,12 @@ local min_inv_size = 4 * 8 -- display and provide at least this many slots
|
|||||||
|
|
||||||
bones = {}
|
bones = {}
|
||||||
|
|
||||||
|
|
||||||
local function NS(s)
|
local function NS(s)
|
||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function is_owner(pos, name)
|
local function is_owner(pos, name)
|
||||||
local owner = minetest.get_meta(pos):get_string("owner")
|
local owner = minetest.get_meta(pos):get_string("owner")
|
||||||
if owner == "" or owner == name or minetest.check_player_privs(name, "protection_bypass") then
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function appendmulti(tbl,...)
|
local function appendmulti(tbl,...)
|
||||||
for _, v in pairs({...}) do
|
for _, v in pairs({...}) do
|
||||||
table.insert(tbl, v)
|
table.insert(tbl, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function get_bones_formspec_for_size(numitems)
|
local function get_bones_formspec_for_size(numitems)
|
||||||
local cols, rows
|
local cols, rows
|
||||||
local scroll=false
|
local scroll=false
|
||||||
@ -61,9 +65,11 @@ local function get_bones_formspec_for_size(numitems)
|
|||||||
return table.concat(output)
|
return table.concat(output)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local share_bones_time = tonumber(minetest.settings:get("share_bones_time")) or 1200
|
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 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)
|
local function find_next_empty(inv,listname,start)
|
||||||
while start <= inv:get_size(listname) do
|
while start <= inv:get_size(listname) do
|
||||||
if inv:get_stack(listname, start):get_count() == 0 then
|
if inv:get_stack(listname, start):get_count() == 0 then
|
||||||
@ -74,6 +80,7 @@ local function find_next_empty(inv,listname,start)
|
|||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function find_next_populated(inv, listname, start)
|
local function find_next_populated(inv, listname, start)
|
||||||
while start <= inv:get_size(listname) do
|
while start <= inv:get_size(listname) do
|
||||||
if inv:get_stack(listname, start):get_count() > 0 then
|
if inv:get_stack(listname, start):get_count() > 0 then
|
||||||
@ -84,6 +91,7 @@ local function find_next_populated(inv, listname, start)
|
|||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- slot reordering to make sure the first rows of the bone are always populated
|
-- slot reordering to make sure the first rows of the bone are always populated
|
||||||
local function bones_inv_reorder(meta)
|
local function bones_inv_reorder(meta)
|
||||||
local next_empty = 1 -- there are no empty slots inside the bones before this
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local bones_def = {
|
local bones_def = {
|
||||||
description = S("Bones"),
|
description = S("Bones"),
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -213,10 +222,12 @@ local bones_def = {
|
|||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
default.set_inventory_action_loggers(bones_def, "bones")
|
default.set_inventory_action_loggers(bones_def, "bones")
|
||||||
|
|
||||||
minetest.register_node("bones:bones", bones_def)
|
minetest.register_node("bones:bones", bones_def)
|
||||||
|
|
||||||
|
|
||||||
local function may_replace(pos, player)
|
local function may_replace(pos, player)
|
||||||
local node_name = minetest.get_node(pos).name
|
local node_name = minetest.get_node(pos).name
|
||||||
local node_definition = minetest.registered_nodes[node_name]
|
local node_definition = minetest.registered_nodes[node_name]
|
||||||
@ -252,7 +263,8 @@ local function may_replace(pos, player)
|
|||||||
return node_definition.buildable_to
|
return node_definition.buildable_to
|
||||||
end
|
end
|
||||||
|
|
||||||
local drop = function(pos, itemstack)
|
|
||||||
|
local function drop(pos, itemstack)
|
||||||
local obj = minetest.add_item(pos, itemstack:take_item(itemstack:get_count()))
|
local obj = minetest.add_item(pos, itemstack:take_item(itemstack:get_count()))
|
||||||
if obj then
|
if obj then
|
||||||
obj:set_velocity({
|
obj:set_velocity({
|
||||||
@ -263,14 +275,17 @@ local drop = function(pos, itemstack)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
bones.player_inventory_lists = { "main", "craft" }
|
bones.player_inventory_lists = { "main", "craft" }
|
||||||
|
|
||||||
local collect_items_callbacks = {}
|
local collect_items_callbacks = {}
|
||||||
|
|
||||||
|
|
||||||
function bones.register_collect_items(func)
|
function bones.register_collect_items(func)
|
||||||
table.insert(collect_items_callbacks, func)
|
table.insert(collect_items_callbacks, func)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
bones.register_collect_items(function(player)
|
bones.register_collect_items(function(player)
|
||||||
local items = {}
|
local items = {}
|
||||||
local player_inv = player:get_inventory()
|
local player_inv = player:get_inventory()
|
||||||
@ -291,6 +306,7 @@ bones.register_collect_items(function(player)
|
|||||||
return items
|
return items
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
local function collect_items(player, player_name)
|
local function collect_items(player, player_name)
|
||||||
if minetest.is_creative_enabled(player_name) then
|
if minetest.is_creative_enabled(player_name) then
|
||||||
return {}
|
return {}
|
||||||
@ -303,6 +319,7 @@ local function collect_items(player, player_name)
|
|||||||
return items
|
return items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Try to find the closest space near the player to place bones
|
-- Try to find the closest space near the player to place bones
|
||||||
local function find_bones_pos(player)
|
local function find_bones_pos(player)
|
||||||
local rounded_player_pos = vector.round(player:get_pos())
|
local rounded_player_pos = vector.round(player:get_pos())
|
||||||
@ -315,6 +332,7 @@ local function find_bones_pos(player)
|
|||||||
return bones_pos
|
return bones_pos
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function place_bones(player, bones_pos, items)
|
local function place_bones(player, bones_pos, items)
|
||||||
local param2 = minetest.dir_to_facedir(player:get_look_dir())
|
local param2 = minetest.dir_to_facedir(player:get_look_dir())
|
||||||
minetest.set_node(bones_pos, {name = "bones:bones", param2 = param2})
|
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
|
return leftover_items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player)
|
minetest.register_on_dieplayer(function(player)
|
||||||
local bones_mode = minetest.settings:get("bones_mode") or "bones"
|
local bones_mode = minetest.settings:get("bones_mode") or "bones"
|
||||||
if bones_mode ~= "bones" and bones_mode ~= "drop" and bones_mode ~= "keep" then
|
if bones_mode ~= "bones" and bones_mode ~= "drop" and bones_mode ~= "keep" then
|
||||||
|
Loading…
Reference in New Issue
Block a user