Fixed some bugs, added HUD status to dump of mod state to log,
changed the default set of generators, using levels only for now
This commit is contained in:
parent
66508f1615
commit
1f2bcc5f81
|
@ -4,13 +4,14 @@ multi_map.layers_start_chunk = 0 -- Y level where to start generating layers, in
|
||||||
multi_map.layer_height_chunks = 32 -- Height of each layer, in chunks
|
multi_map.layer_height_chunks = 32 -- Height of each layer, in chunks
|
||||||
|
|
||||||
-- Either MT engine defaults or derived from above values, to be used for more readable calculations
|
-- Either MT engine defaults or derived from above values, to be used for more readable calculations
|
||||||
multi_map.layer_height = multi_map.layer_height_chunks * 80
|
multi_map.layer_height = nil
|
||||||
multi_map.layers_start = multi_map.layers_start_chunk * 80
|
multi_map.half_layer_height = nil
|
||||||
|
multi_map.layers_start = nil
|
||||||
|
multi_map.current_layer = nil
|
||||||
|
|
||||||
multi_map.map_height = 61840
|
multi_map.map_height = 61840
|
||||||
multi_map.map_min = -30912
|
multi_map.map_min = -30912
|
||||||
multi_map.map_max = 30927
|
multi_map.map_max = 30927
|
||||||
multi_map.half_layer_height = multi_map.layer_height / 2
|
|
||||||
multi_map.current_layer = nil
|
|
||||||
|
|
||||||
-- Can be overridden with someone's own values
|
-- Can be overridden with someone's own values
|
||||||
multi_map.bedrock = "multi_map_core:bedrock" -- Node to use to fill the bottom of a layer
|
multi_map.bedrock = "multi_map_core:bedrock" -- Node to use to fill the bottom of a layer
|
||||||
|
@ -84,6 +85,10 @@ function multi_map.get_offset_y(y, current_layer)
|
||||||
l = multi_map.current_layer
|
l = multi_map.current_layer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not l then
|
||||||
|
return y
|
||||||
|
end
|
||||||
|
|
||||||
local center_point = multi_map.map_min + multi_map.layers_start + (l * multi_map.layer_height) + multi_map.half_layer_height
|
local center_point = multi_map.map_min + multi_map.layers_start + (l * multi_map.layer_height) + multi_map.half_layer_height
|
||||||
|
|
||||||
if center_point > 0 and y > 0 then
|
if center_point > 0 and y > 0 then
|
||||||
|
@ -301,7 +306,7 @@ end
|
||||||
function multi_map.get_layer_name(layer)
|
function multi_map.get_layer_name(layer)
|
||||||
if multi_map.layer_names[layer] then
|
if multi_map.layer_names[layer] then
|
||||||
return multi_map.layer_names[layer]
|
return multi_map.layer_names[layer]
|
||||||
elseif not multi_map.generators[layer] then
|
elseif multi_map.fallback_generator then
|
||||||
return multi_map.fallback_generator.name
|
return multi_map.fallback_generator.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -356,17 +361,26 @@ multi_map.node = setmetatable({}, {
|
||||||
|
|
||||||
-- Simple init, does a sanity check of the settings and sets the mapgen to singlenode
|
-- Simple init, does a sanity check of the settings and sets the mapgen to singlenode
|
||||||
minetest.register_on_mapgen_init(function(mapgen_params)
|
minetest.register_on_mapgen_init(function(mapgen_params)
|
||||||
if multi_map.layers_start + (multi_map.number_of_layers * multi_map.layer_height) > multi_map.map_height then
|
|
||||||
minetest.log("error", "[multi_map] Number of layers for the given layer height exceeds map height!")
|
|
||||||
end
|
|
||||||
minetest.set_mapgen_params({mgname="singlenode"})
|
minetest.set_mapgen_params({mgname="singlenode"})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local firstrun = true
|
local firstrun = true
|
||||||
|
|
||||||
|
function multi_map.initialized()
|
||||||
|
return not firstrun
|
||||||
|
end
|
||||||
|
|
||||||
-- Here all the magic (or should I say mess...) happens!
|
-- Here all the magic (or should I say mess...) happens!
|
||||||
minetest.register_on_generated(function(minp, maxp)
|
minetest.register_on_generated(function(minp, maxp)
|
||||||
if firstrun then
|
if firstrun then
|
||||||
|
multi_map.layer_height = multi_map.layer_height_chunks * 80
|
||||||
|
multi_map.layers_start = multi_map.layers_start_chunk * 80
|
||||||
|
multi_map.half_layer_height = multi_map.layer_height / 2
|
||||||
|
|
||||||
|
if multi_map.layers_start + (multi_map.number_of_layers * multi_map.layer_height) > multi_map.map_height then
|
||||||
|
minetest.log("error", "[multi_map] Number of layers for the given layer height exceeds map height!")
|
||||||
|
end
|
||||||
|
|
||||||
minetest.log("action", "[multi_map]")
|
minetest.log("action", "[multi_map]")
|
||||||
minetest.log("action", "[multi_map] First on_generated call started, module state:")
|
minetest.log("action", "[multi_map] First on_generated call started, module state:")
|
||||||
minetest.log("action", "[multi_map]")
|
minetest.log("action", "[multi_map]")
|
||||||
|
@ -377,7 +391,7 @@ minetest.register_on_generated(function(minp, maxp)
|
||||||
multi_map.set_current_layer(minp.y)
|
multi_map.set_current_layer(minp.y)
|
||||||
local sidelen = maxp.x - minp.x + 1
|
local sidelen = maxp.x - minp.x + 1
|
||||||
|
|
||||||
if multi_map.current_layer >= multi_map.number_of_layers then
|
if not multi_map.current_layer or multi_map.current_layer >= multi_map.number_of_layers then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ function multi_map.log_state()
|
||||||
minetest.log("action", "[multi_map] - Number of layers: "..multi_map.number_of_layers)
|
minetest.log("action", "[multi_map] - Number of layers: "..multi_map.number_of_layers)
|
||||||
minetest.log("action", "[multi_map] - Layers start at: "..(multi_map.map_min + multi_map.layers_start))
|
minetest.log("action", "[multi_map] - Layers start at: "..(multi_map.map_min + multi_map.layers_start))
|
||||||
minetest.log("action", "[multi_map] - Layer height: "..multi_map.layer_height)
|
minetest.log("action", "[multi_map] - Layer height: "..multi_map.layer_height)
|
||||||
|
minetest.log("action", "[multi_map] - HUD enabled: "..tostring(multi_map.hud.enabled))
|
||||||
|
|
||||||
minetest.log("action", "[multi_map]")
|
minetest.log("action", "[multi_map]")
|
||||||
minetest.log("action", "[multi_map] Registered generators")
|
minetest.log("action", "[multi_map] Registered generators")
|
||||||
|
|
|
@ -27,7 +27,7 @@ minetest.register_on_leaveplayer(function(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function multi_map.update_hud(player)
|
function multi_map.update_hud(player)
|
||||||
if not multi_map.hud.enabled then
|
if not multi_map.hud.enabled or not multi_map.initialized() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ function multi_map.update_hud(player)
|
||||||
|
|
||||||
local hud_text = ""
|
local hud_text = ""
|
||||||
|
|
||||||
if multi_map.hud.display_layer or multi_map.hud.display_layer_name then
|
if layer and (multi_map.hud.display_layer or multi_map.hud.display_layer_name) then
|
||||||
hud_text = hud_text..multi_map.hud.layer_label
|
hud_text = hud_text..multi_map.hud.layer_label
|
||||||
|
|
||||||
if multi_map.hud.display_layer then
|
if multi_map.hud.display_layer then
|
||||||
|
|
|
@ -3,12 +3,20 @@ local multi_map_generators_path = minetest.get_modpath("multi_map_generators")
|
||||||
dofile(multi_map_generators_path.."/mmgen_levels.lua")
|
dofile(multi_map_generators_path.."/mmgen_levels.lua")
|
||||||
--dofile(multi_map_generators_path.."/mmgen_lvm_example.lua")
|
--dofile(multi_map_generators_path.."/mmgen_lvm_example.lua")
|
||||||
dofile(multi_map_generators_path.."/mmgen_simple.lua")
|
dofile(multi_map_generators_path.."/mmgen_simple.lua")
|
||||||
dofile(multi_map_generators_path.."/mmgen_testauri.lua")
|
--dofile(multi_map_generators_path.."/mmgen_testauri.lua")
|
||||||
|
|
||||||
multi_map.register_fallback_generator("Default Simple", mmgen_simple.generate)
|
--multi_map.register_fallback_generator("Default Simple", mmgen_simple.generate)
|
||||||
multi_map.register_generator(9, mmgen_simple.generate, "default:sandstone")
|
--multi_map.register_generator(9, mmgen_simple.generate, "default:sandstone")
|
||||||
multi_map.set_layer_name(9, "Desert")
|
--multi_map.set_layer_name(9, "Desert")
|
||||||
multi_map.register_generator(10, mmgen_levels.generate)
|
--multi_map.register_generator(10, mmgen_levels.generate)
|
||||||
multi_map.register_generator(11, mmgen_testauri.generate)
|
--multi_map.register_generator(11, mmgen_testauri.generate)
|
||||||
multi_map.register_generator(12, mmgen_testauri.generate)
|
--multi_map.register_generator(12, mmgen_testauri.generate)
|
||||||
multi_map.register_generator(13, mmgen_levels.generate)
|
--multi_map.register_generator(13, mmgen_levels.generate)
|
||||||
|
|
||||||
|
multi_map.number_of_layers = 38
|
||||||
|
multi_map.layers_start_chunk = 0
|
||||||
|
multi_map.layer_height_chunks = 20
|
||||||
|
|
||||||
|
multi_map.register_fallback_generator("Default Levels", mmgen_levels.generate)
|
||||||
|
multi_map.register_generator(19, mmgen_levels.generate)
|
||||||
|
multi_map.set_layer_name(19, "Central Layer")
|
||||||
|
|
Loading…
Reference in New Issue