Cleaner implementation of corridor start from dirt
parent
6664e4d551
commit
ac867f56c0
40
init.lua
40
init.lua
|
@ -518,7 +518,7 @@ end
|
||||||
-- Returns <success>, <segments>
|
-- Returns <success>, <segments>
|
||||||
-- success: true if corridor could be placed entirely
|
-- success: true if corridor could be placed entirely
|
||||||
-- segments: Number of segments successfully placed
|
-- segments: Number of segments successfully placed
|
||||||
local function corridor_part(start_point, segment_vector, segment_count, wood, post, first_or_final, up_or_down_prev, first_support)
|
local function corridor_part(start_point, segment_vector, segment_count, wood, post, first_or_final, up_or_down_prev)
|
||||||
local p = {x=start_point.x, y=start_point.y, z=start_point.z}
|
local p = {x=start_point.x, y=start_point.y, z=start_point.z}
|
||||||
local torches = pr:next() < probability_torches_in_segment
|
local torches = pr:next() < probability_torches_in_segment
|
||||||
local dir = {0, 0}
|
local dir = {0, 0}
|
||||||
|
@ -531,9 +531,6 @@ local function corridor_part(start_point, segment_vector, segment_count, wood, p
|
||||||
dir = {0, 1}
|
dir = {0, 1}
|
||||||
torchdir = {3, 2}
|
torchdir = {3, 2}
|
||||||
end
|
end
|
||||||
if first_support == nil then
|
|
||||||
first_support = false
|
|
||||||
end
|
|
||||||
for segmentindex = 0, segment_count-1 do
|
for segmentindex = 0, segment_count-1 do
|
||||||
local dug
|
local dug
|
||||||
if segment_vector.y == 0 then
|
if segment_vector.y == 0 then
|
||||||
|
@ -541,15 +538,6 @@ local function corridor_part(start_point, segment_vector, segment_count, wood, p
|
||||||
else
|
else
|
||||||
dug = Cube(p, 1, {name="air"}, false)
|
dug = Cube(p, 1, {name="air"}, false)
|
||||||
end
|
end
|
||||||
if first_support then
|
|
||||||
WoodSupport(p, wood, post, torches, dir, torchdir)
|
|
||||||
if IsRailSurface({x=p.x,y=p.y-2,z=p.z}) then
|
|
||||||
PlaceRail({x=p.x,y=p.y-1,z=p.z}, damage)
|
|
||||||
else
|
|
||||||
PlaceRail({x=p.x,y=p.y-2,z=p.z}, damage)
|
|
||||||
end
|
|
||||||
first_support = false
|
|
||||||
end
|
|
||||||
if not chaos_mode and segmentindex > 0 and not dug then return false, segmentindex end
|
if not chaos_mode and segmentindex > 0 and not dug then return false, segmentindex end
|
||||||
-- Add wooden platform, if neccessary. To avoid floating rails
|
-- Add wooden platform, if neccessary. To avoid floating rails
|
||||||
if segment_vector.y == 0 then
|
if segment_vector.y == 0 then
|
||||||
|
@ -587,7 +575,7 @@ local function corridor_part(start_point, segment_vector, segment_count, wood, p
|
||||||
return true, segment_count
|
return true, segment_count
|
||||||
end
|
end
|
||||||
|
|
||||||
local function corridor_func(waypoint, coord, sign, up_or_down, up_or_down_next, up_or_down_prev, up, wood, post, first_or_final, damage, no_spawner, first_support)
|
local function corridor_func(waypoint, coord, sign, up_or_down, up_or_down_next, up_or_down_prev, up, wood, post, first_or_final, damage, no_spawner)
|
||||||
local segamount = 3
|
local segamount = 3
|
||||||
if up_or_down then
|
if up_or_down then
|
||||||
segamount = 1
|
segamount = 1
|
||||||
|
@ -619,7 +607,7 @@ local function corridor_func(waypoint, coord, sign, up_or_down, up_or_down_next,
|
||||||
if up_or_down and up == false then
|
if up_or_down and up == false then
|
||||||
Cube(waypoint, 1, {name="air"}, false)
|
Cube(waypoint, 1, {name="air"}, false)
|
||||||
end
|
end
|
||||||
local corridor_dug, corridor_segments_dug = corridor_part(start, vek, segcount, wood, post, first_or_final, up_or_down_prev, first_support)
|
local corridor_dug, corridor_segments_dug = corridor_part(start, vek, segcount, wood, post, first_or_final, up_or_down_prev)
|
||||||
local corridor_vek = {x=vek.x*segcount, y=vek.y*segcount, z=vek.z*segcount}
|
local corridor_vek = {x=vek.x*segcount, y=vek.y*segcount, z=vek.z*segcount}
|
||||||
|
|
||||||
-- nachträglich Schienen legen
|
-- nachträglich Schienen legen
|
||||||
|
@ -807,7 +795,7 @@ local function corridor_func(waypoint, coord, sign, up_or_down, up_or_down_next,
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function start_corridor(waypoint, coord, sign, length, psra, wood, post, damage, no_spawner, first_support)
|
local function start_corridor(waypoint, coord, sign, length, psra, wood, post, damage, no_spawner)
|
||||||
local wp = waypoint
|
local wp = waypoint
|
||||||
local c = coord
|
local c = coord
|
||||||
local s = sign
|
local s = sign
|
||||||
|
@ -851,8 +839,7 @@ local function start_corridor(waypoint, coord, sign, length, psra, wood, post, d
|
||||||
elseif i == 1 then
|
elseif i == 1 then
|
||||||
first_or_final = "first"
|
first_or_final = "first"
|
||||||
end
|
end
|
||||||
wp, no_spawner = corridor_func(wp,c,s, ud, udn, udp, up, wood, post, first_or_final, damage, no_spawner, first_support)
|
wp, no_spawner = corridor_func(wp,c,s, ud, udn, udp, up, wood, post, first_or_final, damage, no_spawner)
|
||||||
first_support = false
|
|
||||||
if wp == false then return end
|
if wp == false then return end
|
||||||
-- Verzweigung?
|
-- Verzweigung?
|
||||||
-- Fork?
|
-- Fork?
|
||||||
|
@ -959,7 +946,12 @@ local function place_corridors(main_cave_coords, psra)
|
||||||
if corridors <= 4 and pr:next(1, 20) >= 11 then
|
if corridors <= 4 and pr:next(1, 20) >= 11 then
|
||||||
centered_crossing = true
|
centered_crossing = true
|
||||||
end
|
end
|
||||||
local from_center_base = size + pr:next(-1,1)
|
-- This moves the start of the corridors in the dirt room back and forth
|
||||||
|
local d_max = 3
|
||||||
|
if floor_diff == 1 and height <= 4 then
|
||||||
|
d_max = d_max + 1
|
||||||
|
end
|
||||||
|
local from_center_base = size - pr:next(1,d_max)
|
||||||
for i=1, math.min(4, corridors) do
|
for i=1, math.min(4, corridors) do
|
||||||
local d = pr:next(1, #dirs)
|
local d = pr:next(1, #dirs)
|
||||||
local dir = dirs[d]
|
local dir = dirs[d]
|
||||||
|
@ -975,21 +967,19 @@ local function place_corridors(main_cave_coords, psra)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local from_center = from_center_base
|
local from_center = from_center_base
|
||||||
if not centered_crossing then
|
if dir.sign then
|
||||||
if dir.sign then
|
from_center = -from_center
|
||||||
from_center = -from_center
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if i == 1 then
|
if i == 1 then
|
||||||
first_corridor = {sign=dir.sign, axis=dir.axis, axis2=dir.axis2, side_offset=side_offset, from_center=from_center}
|
first_corridor = {sign=dir.sign, axis=dir.axis, axis2=dir.axis2, side_offset=side_offset, from_center=from_center}
|
||||||
end
|
end
|
||||||
local coords = vector.add(main_cave_coords, {[dir.axis] = from_center, y=0, [dir.axis2] = side_offset})
|
local coords = vector.add(main_cave_coords, {[dir.axis] = from_center, y=0, [dir.axis2] = side_offset})
|
||||||
start_corridor(coords, dir.axis, dir.sign, pr:next(way_min,way_max), psra, wood, post, damage, false, true)
|
start_corridor(coords, dir.axis, dir.sign, pr:next(way_min,way_max), psra, wood, post, damage, false)
|
||||||
table.remove(dirs, d)
|
table.remove(dirs, d)
|
||||||
end
|
end
|
||||||
if corridors == 5 then
|
if corridors == 5 then
|
||||||
local special_coords = vector.add(main_cave_coords, {[first_corridor.axis2] = -first_corridor.side_offset, y=0, [first_corridor.axis] = first_corridor.from_center})
|
local special_coords = vector.add(main_cave_coords, {[first_corridor.axis2] = -first_corridor.side_offset, y=0, [first_corridor.axis] = first_corridor.from_center})
|
||||||
start_corridor(special_coords, first_corridor.axis, first_corridor.sign, pr:next(way_min,way_max), psra, wood, post, damage, false, true)
|
start_corridor(special_coords, first_corridor.axis, first_corridor.sign, pr:next(way_min,way_max), psra, wood, post, damage, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue