mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-01-09 00:29:33 +01:00
Fix crash in rail corridor generation, fix missing globals warnings, fix floating rail in rail corridors
This commit is contained in:
parent
46ea9e98cc
commit
0dbf3fcd62
3 changed files with 8 additions and 5 deletions
|
@ -197,7 +197,7 @@ local function get_rail_connections(pos, opt)
|
||||||
|
|
||||||
local connections = 0
|
local connections = 0
|
||||||
for i = 1,#CONNECTIONS do
|
for i = 1,#CONNECTIONS do
|
||||||
dir = CONNECTIONS[i]
|
local dir = CONNECTIONS[i]
|
||||||
local neighbor = vector.add(pos, dir)
|
local neighbor = vector.add(pos, dir)
|
||||||
local node = force_get_node(neighbor)
|
local node = force_get_node(neighbor)
|
||||||
local nodedef = minetest.registered_nodes[node.name]
|
local nodedef = minetest.registered_nodes[node.name]
|
||||||
|
@ -347,6 +347,9 @@ local function update_rail_connections(pos, opt)
|
||||||
end
|
end
|
||||||
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
|
-- 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 = {}
|
local neighbors = {}
|
||||||
for i=1,#CONNECTIONS do
|
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 = core.get_node(other_pos)
|
||||||
local other_node_def = core.registered_nodes[other_node.name]
|
local other_node_def = core.registered_nodes[other_node.name]
|
||||||
local railtype = get_path(other_node_def, "_mcl_minecarts","railtype")
|
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})
|
update_rail_connections(other_pos, {convert_neighbors = false})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -80,7 +80,7 @@ end
|
||||||
-- * entity_id - type of cart to create
|
-- * entity_id - type of cart to create
|
||||||
-- * pos: Position of cart
|
-- * pos: Position of cart
|
||||||
-- * pr: pseudorandom
|
-- * 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))
|
local uuid = create_minecart(entity_id, pos, vector.new(1,0,0))
|
||||||
|
|
||||||
-- Fill the cart with loot
|
-- Fill the cart with loot
|
||||||
|
|
|
@ -205,7 +205,7 @@ local function IsRailSurface(pos)
|
||||||
local nodename = minetest.get_node(pos).name
|
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 nodename_above = minetest.get_node({x=pos.x,y=pos.y+2,z=pos.z}).name
|
||||||
local nodedef = minetest.registered_nodes[nodename]
|
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
|
end
|
||||||
|
|
||||||
-- Checks if the node is empty space which requires to be filled by a platform
|
-- 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
|
-- Try to create cart staticdata
|
||||||
local hook = tsm_railcorridors.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)
|
minetest.add_entity(cpos, cart_id, cart_staticdata)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue