Make sure the dirt cube's floor is ground
parent
975651e30e
commit
5a9283bc40
20
init.lua
20
init.lua
|
@ -291,15 +291,16 @@ local function Cube(p, radius, node, replace_air_only, wood, post)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function DirtRoom(p, radius, height, dirt_mode)
|
local function DirtRoom(p, radius, height, dirt_mode)
|
||||||
local y_top = p.y-radius+height+1
|
local y_bottom = p.y
|
||||||
|
local y_top = y_bottom + height + 1
|
||||||
local built_all = true
|
local built_all = true
|
||||||
for xi = p.x-radius, p.x+radius do
|
for xi = p.x-radius, p.x+radius do
|
||||||
for zi = p.z-radius, p.z+radius do
|
for zi = p.z-radius, p.z+radius do
|
||||||
for yi = y_top, p.y-radius, -1 do
|
for yi = y_top, y_bottom, -1 do
|
||||||
local thisnode = minetest.get_node({x=xi,y=yi,z=zi})
|
local thisnode = minetest.get_node({x=xi,y=yi,z=zi})
|
||||||
local built = false
|
local built = false
|
||||||
if xi == p.x-radius or xi == p.x+radius or zi == p.z-radius or zi == p.z+radius or yi == p.y-radius or yi == y_top then
|
if xi == p.x-radius or xi == p.x+radius or zi == p.z-radius or zi == p.z+radius or yi == y_bottom or yi == y_top then
|
||||||
if dirt_mode == 1 or yi == p.y-radius then
|
if dirt_mode == 1 or yi == y_bottom then
|
||||||
built = SetNodeIfCanBuild({x=xi,y=yi,z=zi}, {name=tsm_railcorridors.nodes.dirt})
|
built = SetNodeIfCanBuild({x=xi,y=yi,z=zi}, {name=tsm_railcorridors.nodes.dirt})
|
||||||
elseif (dirt_mode == 2 or dirt_mode == 3) and yi == y_top then
|
elseif (dirt_mode == 2 or dirt_mode == 3) and yi == y_top then
|
||||||
if minetest.get_item_group(thisnode.name, "falling_node") == 1 then
|
if minetest.get_item_group(thisnode.name, "falling_node") == 1 then
|
||||||
|
@ -889,11 +890,14 @@ local function spawn_carts()
|
||||||
carts_table = {}
|
carts_table = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Start generation of a rail corridor system
|
||||||
|
-- main_cave_coords is the center of the floor of the dirt room, from which
|
||||||
|
-- all corridors expand.
|
||||||
local function place_corridors(main_cave_coords, psra)
|
local function place_corridors(main_cave_coords, psra)
|
||||||
--[[ ALWAYS start building in the ground. Prevents corridors starting
|
--[[ Start building in the ground. Prevents corridors starting
|
||||||
in mid-air or in liquids. ]]
|
in mid-air or in liquids. ]]
|
||||||
if not IsGround(main_cave_coords) then
|
if not IsGround(main_cave_coords) then
|
||||||
return
|
return false
|
||||||
end
|
end
|
||||||
local center_node = minetest.get_node(main_cave_coords)
|
local center_node = minetest.get_node(main_cave_coords)
|
||||||
|
|
||||||
|
@ -916,7 +920,7 @@ local function place_corridors(main_cave_coords, psra)
|
||||||
local dirt_mode = pr:next(1,2)
|
local dirt_mode = pr:next(1,2)
|
||||||
|
|
||||||
DirtRoom(main_cave_coords, size, height, dirt_mode)
|
DirtRoom(main_cave_coords, size, height, dirt_mode)
|
||||||
main_cave_coords.y =main_cave_coords.y-(size-2-floor_diff)
|
main_cave_coords.y = main_cave_coords.y + 2 + floor_diff
|
||||||
|
|
||||||
-- Get wood and fence post types, using gameconfig.
|
-- Get wood and fence post types, using gameconfig.
|
||||||
|
|
||||||
|
@ -1008,6 +1012,8 @@ local function place_corridors(main_cave_coords, psra)
|
||||||
-- At this point, all corridors were generated and all nodes were set.
|
-- At this point, all corridors were generated and all nodes were set.
|
||||||
-- We spawn the carts now
|
-- We spawn the carts now
|
||||||
spawn_carts()
|
spawn_carts()
|
||||||
|
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The rail corridor algorithm starts here
|
-- The rail corridor algorithm starts here
|
||||||
|
|
Loading…
Reference in New Issue