mirror of
https://github.com/joe7575/techpack.git
synced 2024-12-25 15:14:31 +01:00
add LBM to re-place tops of missing multiblocks
This commit is contained in:
parent
008c1a466d
commit
0c929b2278
@ -1,36 +1,67 @@
|
||||
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"},
|
||||
local bottoms_by_top = {
|
||||
["tubelib_addons1:fermenter_top"] = {"tubelib_addons1:fermenter", "tubelib_addons1:fermenter_defect"},
|
||||
["tubelib_addons1:reformer_top"] = {"tubelib_addons1:reformer", "tubelib_addons1:reformer_defect"},
|
||||
}
|
||||
|
||||
local top_by_bottom = {
|
||||
["tubelib_addons1:fermenter"] = "tubelib_addons1:fermenter_top",
|
||||
["tubelib_addons1:fermenter_defect"] = "tubelib_addons1:fermenter_top",
|
||||
["tubelib_addons1:reformer"] = "tubelib_addons1:reformer_top",
|
||||
["tubelib_addons1:reformer_defect"] = "tubelib_addons1:reformer_top",
|
||||
}
|
||||
|
||||
-- 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)
|
||||
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_top[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
|
||||
if not node_under then
|
||||
-- not loaded
|
||||
return
|
||||
end
|
||||
|
||||
local node_under_name = node_under.name
|
||||
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
|
||||
for _, bottom in ipairs(bottoms) do
|
||||
if node_under_name == bottom then
|
||||
-- has an acceptable bottom
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
})
|
||||
|
||||
-- fix multiblocks with missing tops; happens due to bugs or worldedit
|
||||
minetest.register_lbm({
|
||||
label = "Fix missing tops of multiblocks",
|
||||
name = "tubelib_addons1:fix_missing_tops",
|
||||
nodenames = {
|
||||
"tubelib_addons1:fermenter",
|
||||
"tubelib_addons1:fermenter_defect",
|
||||
"tubelib_addons1:reformer",
|
||||
"tubelib_addons1:reformer_defect",
|
||||
},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
local pos_above = vector.add(pos, vector.new(0, 1, 0))
|
||||
local node_above = minetest.get_node(pos_above)
|
||||
|
||||
if node_above.name ~= "air" then
|
||||
return
|
||||
end
|
||||
|
||||
local top = top_by_bottom[node.name]
|
||||
minetest.add_node(pos_above, {name=top, param2=node.param2})
|
||||
end
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user