mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2025-01-08 17:47:30 +01:00
Add curve->tee and tee->cross conversion logic, fix typo
This commit is contained in:
parent
929d7a6492
commit
9b647b0823
@ -283,7 +283,6 @@ local function bend_straight_rail(pos, towards)
|
|||||||
local dir2_connected = is_rail_end_connected(pos + dir2, dir1)
|
local dir2_connected = is_rail_end_connected(pos + dir2, dir1)
|
||||||
if dir1_connected and dir2_connected then return end
|
if dir1_connected and dir2_connected then return end
|
||||||
|
|
||||||
-- TODO: bend the rail
|
|
||||||
local connections = {
|
local connections = {
|
||||||
vector.direction(pos, towards),
|
vector.direction(pos, towards),
|
||||||
}
|
}
|
||||||
@ -307,8 +306,6 @@ local function bend_straight_rail(pos, towards)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function update_rail_connections(pos, opt)
|
local function update_rail_connections(pos, opt)
|
||||||
local ignore_neighbor_connections = opt and opt.ignore_neighbor_connections
|
|
||||||
|
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local nodedef = minetest.registered_nodes[node.name]
|
local nodedef = minetest.registered_nodes[node.name]
|
||||||
if not nodedef or not nodedef._mcl_minecarts then return end
|
if not nodedef or not nodedef._mcl_minecarts then return end
|
||||||
@ -333,7 +330,7 @@ local function update_rail_connections(pos, opt)
|
|||||||
for i = 1,#CONNECTIONS do
|
for i = 1,#CONNECTIONS do
|
||||||
local dir = CONNECTIONS[i]
|
local dir = CONNECTIONS[i]
|
||||||
local neighbor = vector.add(pos, dir)
|
local neighbor = vector.add(pos, dir)
|
||||||
make_sloped_if_straight( vector.offset(neighbor, 0, -1, 0), dir )
|
make_sloped_if_straight(vector.offset(neighbor, 0, -1, 0), dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
apply_connection_rules(node, nodedef, pos, rules, connections)
|
apply_connection_rules(node, nodedef, pos, rules, connections)
|
||||||
@ -350,6 +347,20 @@ local function update_rail_connections(pos, opt)
|
|||||||
end
|
end
|
||||||
end
|
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
|
||||||
|
local dir = CONNECTIONS[i]
|
||||||
|
if is_connection(pos, dir) then
|
||||||
|
local other_pos = pos - dir
|
||||||
|
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
|
||||||
|
update_rail_connections(other_pos, {convert_neighbors = false})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
mod.update_rail_connections = update_rail_connections
|
mod.update_rail_connections = update_rail_connections
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ local south = mod.south
|
|||||||
local east = mod.east
|
local east = mod.east
|
||||||
local west = mod.west
|
local west = mod.west
|
||||||
|
|
||||||
--- Rail direction Handleres
|
--- Rail direction Handlers
|
||||||
local function rail_dir_straight(pos, dir, node)
|
local function rail_dir_straight(pos, dir, node)
|
||||||
dir = vector.new(dir)
|
dir = vector.new(dir)
|
||||||
dir.y = 0
|
dir.y = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user