mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-30 22:41:20 +01:00
Implement movement thru tee rails
This commit is contained in:
parent
fe3e783f6f
commit
c04ed709e0
2 changed files with 61 additions and 6 deletions
|
@ -32,7 +32,7 @@ mod.detach_minecart = detach_minecart
|
||||||
local function try_detach_minecart(staticdata)
|
local function try_detach_minecart(staticdata)
|
||||||
if not staticdata or not staticdata.connected_at then return end
|
if not staticdata or not staticdata.connected_at then return end
|
||||||
if not mod:is_rail(staticdata.connected_at) then
|
if not mod:is_rail(staticdata.connected_at) then
|
||||||
print("Detaching minecart"..tostring(staticdata.uuid))
|
print("Detaching minecart #"..tostring(staticdata.uuid))
|
||||||
detach_minecart(staticdata)
|
detach_minecart(staticdata)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -89,11 +89,65 @@ local function rail_dir_curve(pos, dir, node)
|
||||||
if vector.equals(dir, east) then return east end
|
if vector.equals(dir, east) then return east end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function rail_dir_tee(pos, dir, node)
|
|
||||||
|
|
||||||
|
local function rail_dir_tee_off(pos, dir, node)
|
||||||
dir = vector.new(dir.x, 0, dir.z)
|
dir = vector.new(dir.x, 0, dir.z)
|
||||||
|
|
||||||
minetest.log("warning","TODO: implement rail_dir_tee()")
|
if node.param2 == 0 then -- north
|
||||||
return north
|
-- South and East
|
||||||
|
if vector.equals(dir, south) then return south end
|
||||||
|
if vector.equals(dir, north) then return east end
|
||||||
|
if vector.equals(dir, west) then return south end
|
||||||
|
if vector.equals(dir, east) then return east end
|
||||||
|
elseif node.param2 == 1 then -- east
|
||||||
|
-- South and West
|
||||||
|
if vector.equals(dir, south) then return south end
|
||||||
|
if vector.equals(dir, north) then return west end
|
||||||
|
if vector.equals(dir, west) then return west end
|
||||||
|
if vector.equals(dir, east) then return south end
|
||||||
|
elseif node.param2 == 2 then
|
||||||
|
-- North and West
|
||||||
|
if vector.equals(dir, south) then return west end
|
||||||
|
if vector.equals(dir, north) then return north end
|
||||||
|
if vector.equals(dir, west) then return west end
|
||||||
|
if vector.equals(dir, east) then return north end
|
||||||
|
elseif node.param2 == 3 then
|
||||||
|
-- North and East
|
||||||
|
if vector.equals(dir, south) then return east end
|
||||||
|
if vector.equals(dir, north) then return north end
|
||||||
|
if vector.equals(dir, west) then return north end
|
||||||
|
if vector.equals(dir, east) then return east end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function rail_dir_tee_on(pos, dir, node)
|
||||||
|
dir = vector.new(dir.x, 0, dir.z)
|
||||||
|
|
||||||
|
if node.param2 == 0 then -- north
|
||||||
|
-- South and East
|
||||||
|
if vector.equals(dir, south) then return east end
|
||||||
|
if vector.equals(dir, north) then return north end
|
||||||
|
if vector.equals(dir, west) then return north end
|
||||||
|
if vector.equals(dir, east) then return east end
|
||||||
|
elseif node.param2 == 1 then -- east
|
||||||
|
-- South and West
|
||||||
|
if vector.equals(dir, south) then return south end
|
||||||
|
if vector.equals(dir, north) then return east end
|
||||||
|
if vector.equals(dir, west) then return south end
|
||||||
|
if vector.equals(dir, east) then return east end
|
||||||
|
elseif node.param2 == 2 then
|
||||||
|
-- North and West
|
||||||
|
if vector.equals(dir, south) then return south end
|
||||||
|
if vector.equals(dir, north) then return west end
|
||||||
|
if vector.equals(dir, west) then return west end
|
||||||
|
if vector.equals(dir, east) then return south end
|
||||||
|
elseif node.param2 == 3 then
|
||||||
|
-- North and East
|
||||||
|
if vector.equals(dir, south) then return west end
|
||||||
|
if vector.equals(dir, north) then return north end
|
||||||
|
if vector.equals(dir, west) then return west end
|
||||||
|
if vector.equals(dir, east) then return north end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
local function rail_dir_cross(pos, dir, node)
|
local function rail_dir_cross(pos, dir, node)
|
||||||
dir = vector.new(dir.x, 0, dir.z)
|
dir = vector.new(dir.x, 0, dir.z)
|
||||||
|
@ -292,13 +346,14 @@ function mod.register_curves_rail(base_name, tiles, def)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_mcl_minecarts = {
|
_mcl_minecarts = {
|
||||||
railtype = "corner",
|
get_next_dir = rail_dir_tee_off,
|
||||||
|
railtype = "tee",
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
mod.register_rail(base_name.."_tee_on", table_merge(table.copy(base_def),{
|
mod.register_rail(base_name.."_tee_on", table_merge(table.copy(base_def),{
|
||||||
tiles = { tiles[4] },
|
tiles = { tiles[4] },
|
||||||
_mcl_minecarts = {
|
_mcl_minecarts = {
|
||||||
get_next_dir = rail_dir_tee,
|
get_next_dir = rail_dir_tee_on,
|
||||||
railtype = "tee",
|
railtype = "tee",
|
||||||
},
|
},
|
||||||
mesecons = {
|
mesecons = {
|
||||||
|
|
Loading…
Reference in a new issue