diff --git a/mods/ENTITIES/mcl_minecarts/functions.lua b/mods/ENTITIES/mcl_minecarts/functions.lua index 026f1ffc9..db981981f 100644 --- a/mods/ENTITIES/mcl_minecarts/functions.lua +++ b/mods/ENTITIES/mcl_minecarts/functions.lua @@ -197,7 +197,7 @@ local function get_rail_connections(pos, opt) local connections = 0 for i = 1,#CONNECTIONS do - dir = CONNECTIONS[i] + local dir = CONNECTIONS[i] local neighbor = vector.add(pos, dir) local node = force_get_node(neighbor) local nodedef = minetest.registered_nodes[node.name] @@ -347,6 +347,9 @@ local function update_rail_connections(pos, opt) end end + -- Recursion guard + if opt and opt.convert_neighbors == false then return end + -- Check if the open end of this rail runs into a corner or a tee and convert that node into a tee or a cross local neighbors = {} for i=1,#CONNECTIONS do @@ -356,7 +359,7 @@ local function update_rail_connections(pos, opt) local other_node = core.get_node(other_pos) local other_node_def = core.registered_nodes[other_node.name] local railtype = get_path(other_node_def, "_mcl_minecarts","railtype") - if (not opt or opt.convert_neighbors ~= false) and railtype == "corner" or railtype == "tee" then + if railtype == "corner" or railtype == "tee" then update_rail_connections(other_pos, {convert_neighbors = false}) end end diff --git a/mods/MAPGEN/tsm_railcorridors/gameconfig.lua b/mods/MAPGEN/tsm_railcorridors/gameconfig.lua index 177ddef9d..084dacb34 100644 --- a/mods/MAPGEN/tsm_railcorridors/gameconfig.lua +++ b/mods/MAPGEN/tsm_railcorridors/gameconfig.lua @@ -80,7 +80,7 @@ end -- * entity_id - type of cart to create -- * pos: Position of cart -- * pr: pseudorandom -function tsm_railcorridors.create_cart_staticdata(entity_id, pos, pr) +function tsm_railcorridors.create_cart_staticdata(entity_id, pos, pr, pr_carts) local uuid = create_minecart(entity_id, pos, vector.new(1,0,0)) -- Fill the cart with loot diff --git a/mods/MAPGEN/tsm_railcorridors/init.lua b/mods/MAPGEN/tsm_railcorridors/init.lua index 8f1de762c..2d9043ae7 100644 --- a/mods/MAPGEN/tsm_railcorridors/init.lua +++ b/mods/MAPGEN/tsm_railcorridors/init.lua @@ -205,7 +205,7 @@ local function IsRailSurface(pos) local nodename = minetest.get_node(pos).name local nodename_above = minetest.get_node({x=pos.x,y=pos.y+2,z=pos.z}).name local nodedef = minetest.registered_nodes[nodename] - return nodename ~= "unknown" and nodename ~= "ignore" and nodedef and nodedef.walkable and (nodedef.node_box == nil or nodedef.node_box.type == "regular") and nodename_above ~= tsm_railcorridors.nodes.rail + return nodename ~= "unknown" and nodename ~= "ignore" and nodedef and nodedef.walkable and (nodedef.node_box == nil or nodedef.node_box.type == "regular") and nodename_above ~= tsm_railcorridors.nodes.rail and nodename ~= tsm_railcorridors.nodes.rail end -- Checks if the node is empty space which requires to be filled by a platform @@ -924,7 +924,7 @@ local function spawn_carts() -- Try to create cart staticdata local hook = tsm_railcorridors.create_cart_staticdata - if hook then cart_staticdata = hook(cart_id, cpos, pr) end + if hook then cart_staticdata = hook(cart_id, cpos, pr, pr_carts) end minetest.add_entity(cpos, cart_id, cart_staticdata) end