1
0
Fork 0

Fix damaging anvil too aggressively

This commit is contained in:
Wuzzy 2018-02-03 03:43:28 +01:00
parent 9277bf4552
commit 0b80b60cf1
1 changed files with 18 additions and 16 deletions

View File

@ -242,17 +242,18 @@ local anvildef = {
end end
update_anvil_slots(meta) update_anvil_slots(meta)
local destroyed = damage_anvil(pos, player) if from_list == "output" then
-- Close formspec if anvil was destroyed local destroyed = damage_anvil(pos, player)
if destroyed then -- Close formspec if anvil was destroyed
--[[ Closing the formspec w/ emptyformname is discouraged. But this is justified if destroyed then
because node formspecs seem to only have an empty formname in MT 0.4.16. --[[ Closing the formspec w/ emptyformname is discouraged. But this is justified
Also, sice this is on_metadata_inventory_take, we KNOW which formspec has because node formspecs seem to only have an empty formname in MT 0.4.16.
been opened by the player. So this should be safe nonetheless. Also, sice this is on_metadata_inventory_take, we KNOW which formspec has
TODO: Update this line when node formspecs get proper identifiers in Minetest. ]] been opened by the player. So this should be safe nonetheless.
minetest.close_formspec(player:get_player_name(), "") TODO: Update this line when node formspecs get proper identifiers in Minetest. ]]
minetest.close_formspec(player:get_player_name(), "")
end
end end
end, end,
on_metadata_inventory_take = function(pos, listname, index, stack, player) on_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -272,12 +273,13 @@ local anvildef = {
end end
end end
update_anvil_slots(meta) update_anvil_slots(meta)
local destroyed = damage_anvil(pos, player) if listname == "output" then
local destroyed = damage_anvil(pos, player)
-- Close formspec if anvil was destroyed -- Close formspec if anvil was destroyed
if destroyed then if destroyed then
-- See above for justification. -- See above for justification.
minetest.close_formspec(player:get_player_name(), "") minetest.close_formspec(player:get_player_name(), "")
end
end end
end, end,
on_construct = function(pos) on_construct = function(pos)