Make old rails have a drawtype, make update lbm always run

This commit is contained in:
teknomunk 2024-05-04 06:33:41 +00:00
parent aefdb963de
commit e4aef86352

View file

@ -374,9 +374,12 @@ local CURVY_RAILS_MAP = {
["mcl_minecarts:rail"] = "mcl_minecarts:rail_v2", ["mcl_minecarts:rail"] = "mcl_minecarts:rail_v2",
} }
for old,new in pairs(CURVY_RAILS_MAP) do for old,new in pairs(CURVY_RAILS_MAP) do
nodenames = mcl_util.table_keys(STRAIGHT_RAILS_MAP),
minetest.register_node(old, { minetest.register_node(old, {
inventory_image = minetest.registered_nodes[new].inventory_image, drawtype = "raillike",
groups = { rail = 1 } inventory_image = new_def.inventory_image,
groups = { rail = 1 },
tiles = { new_def.tiles[1], new_def.tiles[1], new_def.tiles[1], new_def.tiles[1] },
}) })
end end
minetest.register_lbm({ minetest.register_lbm({
@ -399,9 +402,12 @@ local STRAIGHT_RAILS_MAP ={
["mcl_minecarts:detector_rail_on"] = "mcl_minecarts:detector_rail_v2_on", ["mcl_minecarts:detector_rail_on"] = "mcl_minecarts:detector_rail_v2_on",
} }
for old,new in pairs(STRAIGHT_RAILS_MAP) do for old,new in pairs(STRAIGHT_RAILS_MAP) do
local new_def = minetest.registered_nodes[new]
minetest.register_node(old, { minetest.register_node(old, {
inventory_image = minetest.registered_nodes[new].inventory_image, drawtype = "raillike",
groups = { rail = 1 } inventory_image = new_def.inventory_image,
groups = { rail = 1 },
tiles = { new_def.tiles[1], new_def.tiles[1], new_def.tiles[1], new_def.tiles[1] },
}) })
end end
local TRANSLATE_RAILS_MAP = table.copy(STRAIGHT_RAILS_MAP) local TRANSLATE_RAILS_MAP = table.copy(STRAIGHT_RAILS_MAP)
@ -410,6 +416,7 @@ table_merge(TRANSLATE_RAILS_MAP, CURVY_RAILS_MAP)
minetest.register_lbm({ minetest.register_lbm({
name = "mcl_minecarts:update_legacy_straight_rails", name = "mcl_minecarts:update_legacy_straight_rails",
nodenames = mcl_util.table_keys(STRAIGHT_RAILS_MAP), nodenames = mcl_util.table_keys(STRAIGHT_RAILS_MAP),
run_at_every_load = true,
action = function(pos, node) action = function(pos, node)
node.name = STRAIGHT_RAILS_MAP[node.name] node.name = STRAIGHT_RAILS_MAP[node.name]
if node.name then if node.name then