Allow t-junctions at forks
parent
18143a65f0
commit
494830b44a
50
init.lua
50
init.lua
|
@ -438,11 +438,14 @@ local function TryPlaceCobweb(pos, needs_check, side_vector)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function WoodBulk(pos, wood)
|
-- 4 wooden pillars around pos at height
|
||||||
SetNodeIfCanBuild({x=pos.x+1, y=pos.y, z=pos.z+1}, {name=wood}, false, true)
|
local function WoodBulk(pos, height, wood)
|
||||||
SetNodeIfCanBuild({x=pos.x-1, y=pos.y, z=pos.z+1}, {name=wood}, false, true)
|
for y=0, height-1 do
|
||||||
SetNodeIfCanBuild({x=pos.x+1, y=pos.y, z=pos.z-1}, {name=wood}, false, true)
|
SetNodeIfCanBuild({x=pos.x+1, y=pos.y+y, z=pos.z+1}, {name=wood}, false, true)
|
||||||
SetNodeIfCanBuild({x=pos.x-1, y=pos.y, z=pos.z-1}, {name=wood}, false, true)
|
SetNodeIfCanBuild({x=pos.x-1, y=pos.y+y, z=pos.z+1}, {name=wood}, false, true)
|
||||||
|
SetNodeIfCanBuild({x=pos.x+1, y=pos.y+y, z=pos.z-1}, {name=wood}, false, true)
|
||||||
|
SetNodeIfCanBuild({x=pos.x-1, y=pos.y+y, z=pos.z-1}, {name=wood}, false, true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Build a wooden support frame
|
-- Build a wooden support frame
|
||||||
|
@ -844,17 +847,36 @@ local function start_corridor(waypoint, coord, sign, length, wood, post, damage,
|
||||||
end
|
end
|
||||||
wp, no_spawner = corridor_func(wp,c,s, ud, udn, udp, up, wood, post, first_or_final, damage, no_spawner)
|
wp, no_spawner = corridor_func(wp,c,s, ud, udn, udp, up, wood, post, first_or_final, damage, no_spawner)
|
||||||
if wp == false then return end
|
if wp == false then return end
|
||||||
-- Fork?
|
-- Fork in the road? If so, starts 2-3 new corridors
|
||||||
if pr:next() < probability_fork then
|
if pr:next() < probability_fork then
|
||||||
|
-- 75% chance to fork off in 3 directions (making a crossing)
|
||||||
|
-- 25% chance to fork off in 2 directions (making a t-junction)
|
||||||
|
local is_crossing = pr:next(0, 3) < 3
|
||||||
|
local forks = 2
|
||||||
|
if is_crossing then
|
||||||
|
forks = 3
|
||||||
|
end
|
||||||
local p = {x=wp.x, y=wp.y, z=wp.z}
|
local p = {x=wp.x, y=wp.y, z=wp.z}
|
||||||
start_corridor(wp, c, s, pr:next(way_min,way_max), wood, post, damage, no_spawner)
|
local c2
|
||||||
if c == "x" then c="z" else c="x" end
|
if c == "x" then
|
||||||
start_corridor(wp, c, s, pr:next(way_min,way_max), wood, post, damage, no_spawner)
|
c2="z"
|
||||||
start_corridor(wp, c, not s, pr:next(way_min,way_max), wood, post, damage, no_spawner)
|
else
|
||||||
WoodBulk({x=p.x, y=p.y-1, z=p.z}, wood)
|
c2="x"
|
||||||
WoodBulk({x=p.x, y=p.y, z=p.z}, wood)
|
end
|
||||||
WoodBulk({x=p.x, y=p.y+1, z=p.z}, wood)
|
local fork_dirs = {
|
||||||
WoodBulk({x=p.x, y=p.y+2, z=p.z}, wood)
|
{c2, s}, -- to the side
|
||||||
|
{c2, not s}, -- to the other side
|
||||||
|
{c, s}, -- straight ahead
|
||||||
|
}
|
||||||
|
for f=1, forks do
|
||||||
|
local r = pr:next(1, #fork_dirs)
|
||||||
|
start_corridor(wp, fork_dirs[r][1], fork_dirs[r][2], pr:next(way_min,way_max), wood, post, damage, no_spawner)
|
||||||
|
table.remove(fork_dirs, r)
|
||||||
|
end
|
||||||
|
if is_crossing then
|
||||||
|
-- 4 large wooden pillars around the center rail
|
||||||
|
WoodBulk({x=p.x, y=p.y-1, z=p.z}, 4, wood)
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- Randomly change sign and coord
|
-- Randomly change sign and coord
|
||||||
|
|
Loading…
Reference in New Issue