Skip to content

Commit

Permalink
Node diggers also eating dungeon chests (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emojigit authored Jan 16, 2024
1 parent 1b4628e commit afd6b87
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions nodes/node_diggers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,27 @@ minetest.register_node("digtron:digger", {
return 0
end

local dignode = minetest.get_node(digpos)

-- default:chest are common in underground dungeons
-- Avoid them interrupting the automation by absorbing all the items in them.
if dignode.name == "default:chest" or dignode.name == "default:chest_open" then
local inv = minetest.get_meta(digpos):get_inventory()
local list_main = inv:get_list("main")
inv:set_list("main", {})
local fuel_cost, dropped = digtron.mark_diggable(digpos, nodes_dug, player)
if dropped then
for _, item in ipairs(list_main) do
if not item:is_empty() then
table.insert(dropped, item)
end
end

return fuel_cost, dropped
else
inv:set_list("main", list_main)
end
end
return digtron.mark_diggable(digpos, nodes_dug, player)
end,

Expand Down

0 comments on commit afd6b87

Please sign in to comment.