From 2400ca5be067494c7dd1b49c7acf3993dcbbfd5a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 26 Jan 2018 23:43:33 +0100 Subject: [PATCH] Partially fix bad player counting of trapped chest --- mods/ITEMS/mcl_chests/init.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index 5d8ce2be34..a34dc5bbd7 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -5,13 +5,16 @@ if minetest.get_modpath("screwdriver") then end -- This is a helper function to register both chests and trapped chests. Trapped chests will make use of the additional parameters -local register_chest = function(basename, desc, longdesc, usagehelp, tiles_table, hidden, mesecons, on_rightclick_addendum, on_rightclick_addendum_left, on_rightclick_addendum_right, drop) +local register_chest = function(basename, desc, longdesc, usagehelp, tiles_table, hidden, mesecons, on_rightclick_addendum, on_rightclick_addendum_left, on_rightclick_addendum_right, drop, formspec_basename) if not drop then drop = "mcl_chests:"..basename else drop = "mcl_chests:"..drop end +if not formspec_basename then + formspec_basename = basename +end minetest.register_node("mcl_chests:"..basename, { description = desc, @@ -97,7 +100,7 @@ minetest.register_node("mcl_chests:"..basename, { on_rightclick = function(pos, node, clicker) minetest.show_formspec(clicker:get_player_name(), - "mcl_chests:"..basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, + "mcl_chests:"..formspec_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, "size[9,8.75]".. mcl_vars.inventory_header.. "background[-0.19,-0.25;9.41,10.48;mcl_chests_inventory_chest.png]".. @@ -116,7 +119,7 @@ minetest.register_node("mcl_chests:"..basename, { on_destruct = function(pos) local players = minetest.get_connected_players() for p=1, #players do - minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) + minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..formspec_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) end end, mesecons = mesecons, @@ -138,7 +141,7 @@ minetest.register_node("mcl_chests:"..basename.."_left", { local players = minetest.get_connected_players() for p=1, #players do - minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) + minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..formspec_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) end local param2 = n.param2 @@ -212,7 +215,7 @@ minetest.register_node("mcl_chests:"..basename.."_left", { local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left") minetest.show_formspec(clicker:get_player_name(), - "mcl_chests:"..basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, + "mcl_chests:"..formspec_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, "size[9,11.5]".. "background[-0.19,-0.25;9.41,12.5;mcl_chests_inventory_chest_large.png]".. mcl_vars.inventory_header.. @@ -252,7 +255,7 @@ minetest.register_node("mcl_chests:"..basename.."_right", { local players = minetest.get_connected_players() for p=1, #players do - minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) + minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..formspec_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) end local param2 = n.param2 @@ -326,7 +329,7 @@ minetest.register_node("mcl_chests:"..basename.."_right", { local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right") minetest.show_formspec(clicker:get_player_name(), - "mcl_chests:"..basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, + "mcl_chests:"..formspec_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, "size[9,11.5]".. "background[-0.19,-0.25;9.41,12.5;mcl_chests_inventory_chest_large.png]".. @@ -458,6 +461,7 @@ register_chest("trapped_chest_on", players = players + 1 meta:set_int("players", players) end, + "trapped_chest", "trapped_chest" )