Make furnaces always diggable

This commit is contained in:
Wuzzy 2017-01-17 01:57:22 +01:00
parent 5895fcb4b9
commit 31f1126487

View File

@ -1572,17 +1572,19 @@ minetest.register_node("default:furnace", {
inv:set_size("src", 1) inv:set_size("src", 1)
inv:set_size("dst", 4) inv:set_size("dst", 4)
end, end,
can_dig = function(pos,player) after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos)
local meta2 = meta
meta:from_table(oldmetadata)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("fuel") then for _, listname in ipairs({"src", "dst", "fuel"}) do
return false local stack = inv:get_stack(listname, 1)
elseif not inv:is_empty("dst") then if not stack:is_empty() then
return false local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
elseif not inv:is_empty("src") then minetest.add_item(p, stack)
return false end
end end
return true meta:from_table(meta2:to_table())
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -1635,17 +1637,19 @@ minetest.register_node("default:furnace_active", {
inv:set_size("src", 1) inv:set_size("src", 1)
inv:set_size("dst", 4) inv:set_size("dst", 4)
end, end,
can_dig = function(pos,player) after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos)
local meta2 = meta
meta:from_table(oldmetadata)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("fuel") then for _, listname in ipairs({"src", "dst", "fuel"}) do
return false local stack = inv:get_stack(listname, 1)
elseif not inv:is_empty("dst") then if not stack:is_empty() then
return false local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
elseif not inv:is_empty("src") then minetest.add_item(p, stack)
return false end
end end
return true meta:from_table(meta2:to_table())
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)