Fix level clearing routine, add seafloor
parent
7c549ffb46
commit
7e2191205a
|
@ -1,12 +1,14 @@
|
||||||
lzr_globals = {}
|
lzr_globals = {}
|
||||||
|
|
||||||
lzr_globals.PLAYFIELD_START = vector.new(-1, -1, -1)
|
lzr_globals.LEVEL_POS = vector.new(0, 0, 0)
|
||||||
lzr_globals.PLAYFIELD_SIZE = vector.new(21, 21, 21)
|
lzr_globals.PLAYFIELD_START = vector.add(vector.new(-1, -1, -1), lzr_globals.LEVEL_POS)
|
||||||
|
lzr_globals.PLAYFIELD_SIZE = vector.new(22, 22, 22)
|
||||||
lzr_globals.PLAYFIELD_END = vector.add(lzr_globals.PLAYFIELD_START, lzr_globals.PLAYFIELD_SIZE)
|
lzr_globals.PLAYFIELD_END = vector.add(lzr_globals.PLAYFIELD_START, lzr_globals.PLAYFIELD_SIZE)
|
||||||
lzr_globals.LEVEL_POS = vector.zero()
|
|
||||||
lzr_globals.DEFAULT_LEVEL_SIZE = vector.new(10, 6, 10)
|
lzr_globals.DEFAULT_LEVEL_SIZE = vector.new(10, 6, 10)
|
||||||
lzr_globals.MENU_SHIP_POS = vector.new(-500, -4, -500)
|
lzr_globals.MENU_SHIP_POS = vector.new(-500, -4, -500)
|
||||||
lzr_globals.MENU_SHIP_PLAYER_SPAWN_OFFSET = vector.new(7, 8.5, 29)
|
lzr_globals.MENU_SHIP_PLAYER_SPAWN_OFFSET = vector.new(7, 8.5, 29)
|
||||||
lzr_globals.MENU_SHIP_STARTBOOK_OFFSET = vector.new(7, 10, 31)
|
lzr_globals.MENU_SHIP_STARTBOOK_OFFSET = vector.new(7, 10, 31)
|
||||||
lzr_globals.MENU_PLAYER_SPAWN_POS = vector.add(lzr_globals.MENU_SHIP_POS, lzr_globals.MENU_SHIP_PLAYER_SPAWN_OFFSET)
|
lzr_globals.MENU_PLAYER_SPAWN_POS = vector.add(lzr_globals.MENU_SHIP_POS, lzr_globals.MENU_SHIP_PLAYER_SPAWN_OFFSET)
|
||||||
lzr_globals.WATER_LEVEL = 0
|
lzr_globals.WATER_LEVEL = 0
|
||||||
|
lzr_globals.SEABED_LEVEL = -1000
|
||||||
|
lzr_globals.SEASTONE_LEVEL = -1002
|
||||||
|
|
|
@ -133,15 +133,15 @@ function lzr_levels.clear_playfield(room_size)
|
||||||
local posses_air = {}
|
local posses_air = {}
|
||||||
local posses_water = {}
|
local posses_water = {}
|
||||||
local size = lzr_globals.PLAYFIELD_SIZE
|
local size = lzr_globals.PLAYFIELD_SIZE
|
||||||
for z=-1, size.x+1 do
|
for z=0, size.z do
|
||||||
for y=-1, size.y+1 do
|
for y=0, size.y do
|
||||||
for x=-1, size.z+1 do
|
for x=0, size.x do
|
||||||
local pos = vector.new(x,y,z)
|
local pos = vector.new(x,y,z)
|
||||||
pos = vector.add(pos, lzr_globals.LEVEL_POS)
|
pos = vector.add(pos, lzr_globals.PLAYFIELD_START)
|
||||||
if pos.y <= lzr_globals.WATER_LEVEL and (x > room_size.x or z > room_size.z) then
|
if pos.y <= lzr_globals.WATER_LEVEL and (x > room_size.x or z > room_size.z) then
|
||||||
table.insert(posses_water, vector.new(x,y,z))
|
table.insert(posses_water, pos)
|
||||||
else
|
else
|
||||||
table.insert(posses_air, vector.new(x,y,z))
|
table.insert(posses_air, pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,17 +1,26 @@
|
||||||
-- Create ocean
|
-- Create ocean
|
||||||
|
|
||||||
|
local c_water = minetest.get_content_id("lzr_core:water_source")
|
||||||
|
local c_seabed = minetest.get_content_id("lzr_core:seabed")
|
||||||
|
local c_stone = minetest.get_content_id("lzr_core:stone")
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp)
|
minetest.register_on_generated(function(minp, maxp)
|
||||||
if minp.y <= lzr_globals.WATER_LEVEL then
|
if minp.y <= lzr_globals.WATER_LEVEL then
|
||||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
|
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
|
||||||
local c_water = minetest.get_content_id("lzr_core:water_source")
|
|
||||||
|
|
||||||
for x = minp.x, maxp.x do
|
for x = minp.x, maxp.x do
|
||||||
for z = minp.z, maxp.z do
|
for z = minp.z, maxp.z do
|
||||||
for y = minp.y, math.min(lzr_globals.WATER_LEVEL, maxp.y) do
|
for y = minp.y, math.min(lzr_globals.WATER_LEVEL, maxp.y) do
|
||||||
local p_pos = area:index(x, y, z)
|
local p_pos = area:index(x, y, z)
|
||||||
data[p_pos] = c_water
|
if y <= lzr_globals.SEASTONE_LEVEL then
|
||||||
|
data[p_pos] = c_stone
|
||||||
|
elseif y <= lzr_globals.SEABED_LEVEL then
|
||||||
|
data[p_pos] = c_seabed
|
||||||
|
else
|
||||||
|
data[p_pos] = c_water
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue