Fix locked ovens reverting to unlocked.

This commit is contained in:
Diego Martinez 2014-10-01 02:49:17 -03:00
parent 63e697cbb6
commit 27a59c0716

View File

@ -288,11 +288,15 @@ function homedecor.register_furnace(name, furnacedef)
end end
end end
-- XXX: Quick patch, make it better in the future.
local locked = node.name:find("_locked$") and "_locked" or ""
local desc = minetest.registered_nodes[name..locked].description
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
local percent = math.floor(meta:get_float("fuel_time") / local percent = math.floor(meta:get_float("fuel_time") /
meta:get_float("fuel_totaltime") * 100) meta:get_float("fuel_totaltime") * 100)
meta:set_string("infotext",S("%s active: %d%%"):format(desc,percent)) meta:set_string("infotext",S("%s active: %d%%"):format(desc,percent))
hacky_swap_node(pos,name_active) hacky_swap_node(pos,name_active..locked)
meta:set_string("formspec", make_formspec(furnacedef, percent)) meta:set_string("formspec", make_formspec(furnacedef, percent))
return return
end end
@ -312,7 +316,7 @@ function homedecor.register_furnace(name, furnacedef)
if (not fuel) or (fuel.time <= 0) then if (not fuel) or (fuel.time <= 0) then
meta:set_string("infotext",desc..S(": Out of fuel")) meta:set_string("infotext",desc..S(": Out of fuel"))
hacky_swap_node(pos,name) hacky_swap_node(pos,name..locked)
meta:set_string("formspec", make_formspec(furnacedef, 0)) meta:set_string("formspec", make_formspec(furnacedef, 0))
return return
end end
@ -320,7 +324,7 @@ function homedecor.register_furnace(name, furnacedef)
if cooked.item:is_empty() then if cooked.item:is_empty() then
if was_active then if was_active then
meta:set_string("infotext",S("%s is empty"):format(desc)) meta:set_string("infotext",S("%s is empty"):format(desc))
hacky_swap_node(pos,name) hacky_swap_node(pos,name..locked)
meta:set_string("formspec", make_formspec(furnacedef, 0)) meta:set_string("formspec", make_formspec(furnacedef, 0))
end end
return return
@ -328,7 +332,7 @@ function homedecor.register_furnace(name, furnacedef)
if not inv:room_for_item("dst", cooked.item) then if not inv:room_for_item("dst", cooked.item) then
meta:set_string("infotext", desc..S(": output bins are full")) meta:set_string("infotext", desc..S(": output bins are full"))
hacky_swap_node(pos, name) hacky_swap_node(pos, name..locked)
meta:set_string("formspec", make_formspec(furnacedef, 0)) meta:set_string("formspec", make_formspec(furnacedef, 0))
return return
end end