mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-25 16:43:50 +01:00
properly remove entire fermenter and reformer after checking that they don't have contents; add an LBM to remove stranded top nodes
This commit is contained in:
parent
47616daf23
commit
802e5f239d
@ -198,18 +198,14 @@ minetest.register_node("tubelib_addons1:fermenter", {
|
||||
end,
|
||||
|
||||
-- the fermenter needs 'on_dig' to be able to remove the upper node
|
||||
on_dig = function(pos, node, puncher, pointed_thing)
|
||||
on_dig = function(pos, node, player)
|
||||
local meta = M(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("dst") and inv:is_empty("src") then
|
||||
minetest.node_dig(pos, node, puncher, pointed_thing)
|
||||
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
end
|
||||
end,
|
||||
|
||||
on_dig = function(pos, node, player)
|
||||
State:on_dig_node(pos, node, player)
|
||||
tubelib.remove_node(pos)
|
||||
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
end
|
||||
end,
|
||||
|
||||
on_rotate = screwdriver.disallow,
|
||||
|
@ -23,3 +23,4 @@ dofile(minetest.get_modpath("tubelib_addons1") .. "/pusher_fast.lua")
|
||||
dofile(minetest.get_modpath("tubelib_addons1") .. "/detector.lua")
|
||||
dofile(minetest.get_modpath("tubelib_addons1") .. '/chest.lua')
|
||||
dofile(minetest.get_modpath("tubelib_addons1") .. '/liquidsampler.lua')
|
||||
dofile(minetest.get_modpath("tubelib_addons1") .. '/lbms.lua')
|
||||
|
36
tubelib_addons1/lbms.lua
Normal file
36
tubelib_addons1/lbms.lua
Normal file
@ -0,0 +1,36 @@
|
||||
local bottoms_by_node = {
|
||||
["tubelib_addons1:fermenter_top"] = {"tubelib_addons1:fermenter", "tubelib_addons1:fermenter_defect"},
|
||||
["tubelib_addons1:reformer_top"] = {"tubelib_addons1:reformer", "tubelib_addons1:reformer_defect"},
|
||||
}
|
||||
|
||||
-- remove tops of multiblocks which aren't over the bottom; happens due to bugs or worldedit
|
||||
minetest.register_lbm({
|
||||
label = "Remove detached tops of multiblocks",
|
||||
name = "tubelib_addons1:remove_detached_tops",
|
||||
nodenames = {
|
||||
"tubelib_addons1:fermenter_top",
|
||||
"tubelib_addons1:reformer_top",
|
||||
},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
local bottoms = bottoms_by_node[node.name]
|
||||
local pos_under = vector.subtract(pos, vector.new(0, 1, 0))
|
||||
local node_under = minetest.get_node_or_nil(pos_under)
|
||||
|
||||
if not node_under then
|
||||
-- not loaded
|
||||
return
|
||||
end
|
||||
|
||||
local node_under_name = node_under.name
|
||||
|
||||
for _, bottom in ipairs(bottoms) do
|
||||
if node_under_name == bottom then
|
||||
-- has an acceptable bottom
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
})
|
@ -198,16 +198,12 @@ minetest.register_node("tubelib_addons1:reformer", {
|
||||
local meta = M(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("dst") and inv:is_empty("src") then
|
||||
minetest.node_dig(pos, node, puncher, pointed_thing)
|
||||
State:on_dig_node(pos, node, puncher)
|
||||
tubelib.remove_node(pos)
|
||||
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
end
|
||||
end,
|
||||
|
||||
on_dig = function(pos, node, player)
|
||||
State:on_dig_node(pos, node, player)
|
||||
tubelib.remove_node(pos)
|
||||
end,
|
||||
|
||||
on_rotate = screwdriver.disallow,
|
||||
on_timer = keep_running,
|
||||
on_receive_fields = on_receive_fields,
|
||||
|
Loading…
Reference in New Issue
Block a user