Further tweaking of the skyrock and bedrock layers, fixes in lighting

and another refactoring with a first cut of a multi_map class and API
This commit is contained in:
evrooije 2018-07-15 23:42:46 +02:00
parent a626ec05a1
commit f643ce0700
2 changed files with 38 additions and 6 deletions

View File

@ -1,11 +1,38 @@
multi_map = {}
multi_map.number_of_layers = 32
multi_map.day_light = 15
multi_map.night_light = 0
multi_map.bedrock = "multi_map:bedrock"
multi_map.skyrock = "multi_map:skyrock"
multi_map.water_height = 0
multi_map.seed = 835726
multi_map.layer_height = 65535 / multi_map.number_of_layers
multi_map.half_layer_height = multi_map.layer_height / 2
function multi_map.get_current_layer(y)
for l = (multi_map.number_of_layers / -2), (multi_map.number_of_layers / 2) do
if y >= (l * layer_height) - half_layer_height and y < (l * layer_height) + half_layer_height then
return l
end
end
end
function multi_map.get_offset_y(y)
return y - (multi_map.get_current_layer(y) * multi_map.layer_height)
end
minetest.register_node("multi_map:skyrock", {
description = "Multi Map Impenetrable Skyblock",
drawtype = "airlike",
is_ground_content = false,
sunlight_propagates = true,
walkable = true,
pointable = false,
diggable = false,
climbable = false,
paramtype = "light",
})
minetest.register_node("multi_map:bedrock", {

View File

@ -202,6 +202,7 @@ minetest.register_on_generated(function(minp, maxp)
local nixz = 1
local worm_started = false
local supress_shadow = false
for z = minp.z, maxp.z do
local niz
@ -216,10 +217,11 @@ minetest.register_on_generated(function(minp, maxp)
height = height + layers[current_layer].mountain_peak_2dmap[nixz]
end
if (layer_height * current_layer) - half_layer_height <= y and y <= (layer_height * current_layer) - half_layer_height + (sidelen / 2) then
if (layer_height * current_layer) + half_layer_height < y and y <= (layer_height * current_layer) + half_layer_height + sidelen then
vm_data[vi] = c_bedrock
elseif (layer_height * current_layer) + half_layer_height - (sidelen * 5) <= y and y <= (layer_height * current_layer) + half_layer_height then
elseif (layer_height * current_layer) + half_layer_height - (sidelen * 2) <= y and y <= (layer_height * current_layer) + half_layer_height then
vm_data[vi] = c_skyrock
supress_shadow = true
elseif y <= height + (layer_height * current_layer) then
-- if math.abs(cave_3dmap[nixyz]) < 10 then -- + (y / 400) then
vm_data[vi] = c_stone
@ -244,10 +246,13 @@ minetest.register_on_generated(function(minp, maxp)
nixz = nixz + sidelen
end
vm:set_data(vm_data)
vm:set_lighting({day=settings.day_light, night=settings.night_light})
vm:update_liquids()
vm:calc_lighting(false)
vm:write_to_map()
if supress_shadow then
vm:calc_lighting(false)
vm:write_to_map(false)
else
vm:calc_lighting()
vm:write_to_map()
end
end)