initial fixes to make multi map work with mcl

This commit is contained in:
cora 2022-03-24 22:01:05 +01:00
parent 792b695902
commit 63002f643f
9 changed files with 93 additions and 66 deletions

View File

@ -1,2 +1,2 @@
name = multi_map
description = Mulitple layers of map generation for Minetest
name = mcl_multi_map
description = Mulitple layers of map generation for MineClone

View File

@ -259,7 +259,7 @@ multi_map.node = setmetatable({}, {
-- Simple init, does a sanity check of the settings and sets the mapgen to singlenode
minetest.register_on_mapgen_init(function(mapgen_params)
minetest.set_mapgen_params({mgname="singlenode", flags="nolight"})
--minetest.set_mapgen_params({mgname="singlenode", flags="nolight"})
minetest.after(0, function()
multi_map.layer_height = multi_map.layer_height_chunks * 80
multi_map.layers_start = multi_map.layers_start_chunk * 80

View File

@ -1,3 +1,3 @@
name = multi_map_core
description = multi_map core engine and API
depends = default
description = multi_map core engine and API for mineclone
depends = mcl_core

View File

@ -1,36 +1,41 @@
local multi_map_generators_path = minetest.get_modpath("multi_map_generators")
multi_map.number_of_layers = 38
multi_map.layers_start_chunk = 0
multi_map.number_of_layers = 12
multi_map.layers_start_chunk = 500
multi_map.layer_height_chunks = 20
--multi_map.wrap_layers = true
multi_map.wrap_layers = true
dofile(multi_map_generators_path.."/mmgen_levels.lua")
--dofile(multi_map_generators_path.."/mmgen_lvm_example.lua")
dofile(multi_map_generators_path.."/mmgen_simple.lua")
dofile(multi_map_generators_path.."/mmgen_testauri.lua")
dofile(multi_map_generators_path.."/mmgen_mytest.lua")
--multi_map.register_fallback_generator("Default Simple", mmgen_simple.generate)
--multi_map.register_generator(9, mmgen_simple.generate, "default:sandstone")
--multi_map.set_layer_name(9, "Desert")
--multi_map.register_generator(10, mmgen_levels.generate)
--multi_map.register_generator(11, mmgen_testauri.generate)
--multi_map.register_generator(12, mmgen_testauri.generate)
--multi_map.register_generator(13, mmgen_levels.generate)
multi_map.register_fallback_generator("Default Simple", mmgen_simple.generate)
multi_map.register_fallback_generator(mmgen_simple.generate)
multi_map.register_generator(0, mmgen_testauri.generate )
multi_map.register_generator(1, mmgen_mytest.generate, {stone="mcl_core:stone",dirt="mcl_core:dirt",grass="mcl_core:dirt_with_grass",water="mcl_core:water_source",air="air"})
multi_map.register_generator(2, mmgen_simple.generate, {nodetype="mcl_core:dirt"})
multi_map.register_generator(3, mmgen_simple.generate, {nodetype="mcl_core:obsidian"})
multi_map.register_generator(4, mmgen_levels.generate)
--multi_map.register_generator(18, mmgen_testauri.generate)
--multi_map.register_generator(19, mmgen_testauri.generate)
--multi_map.register_generator(20, mmgen_testauri.generate)
multi_map.set_layer_params(0, { name = "testauri" })
multi_map.set_layer_params(1, { name = "testmg"})
multi_map.set_layer_params(2, { name = "Dirt Layer" })
multi_map.set_layer_params(3, { name = "Obby Layer" })
multi_map.set_layer_params(4, { name = "Levels" })
--multi_map.register_linked_layer(19, multi_map.world_edge.POSITIVE_X, 19, true)
--multi_map.register_linked_layer(19, multi_map.world_edge.POSITIVE_Z, 19, true)
multi_map.register_fallback_generator("Default Levels", mmgen_levels.generate)
multi_map.register_generator(18, mmgen_levels.generate)
multi_map.register_generator(19, mmgen_testauri.generate)
multi_map.register_generator(20, mmgen_levels.generate)
multi_map.set_layer_params(18, { name = "Lowlands Layer" })
multi_map.set_layer_params(19, { name = "Central Layer" })
multi_map.set_layer_params(20, { name = "Remote Levels Land" })
for i=0,multi_map.number_of_layers-1 do
multi_map.register_linked_layer(i, multi_map.world_edge.POSITIVE_X, i+1,true)
multi_map.register_linked_layer(i, multi_map.world_edge.NEGATIVE_X, i-1,true)
end
minetest.register_chatcommand("mmtp",{privs={debug=true},func=function(name,param)
local ch = 80
local p=minetest.get_player_by_name(name)
local lp=p:get_pos()
local ty = ( multi_map.layers_start_chunk * ch ) + (tonumber(param) * multi_map.layer_height_chunks * ch) - 30912 + (10 * ch)
p:set_pos(vector.new(lp.x,ty,lp.z))
return true, "tped to layer "..param
end})

View File

@ -58,33 +58,6 @@ multi_map.register_global_2dmap(
}
)
-- Nodes
minetest.register_node("multi_map_generators:grass", {
description = "Grass",
tiles = {"default_grass.png", "default_dirt.png", "default_grass.png"},
groups = {crumbly=3},
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.25},
}),
})
minetest.register_node("multi_map_generators:dirt", {
description = "Dirt",
tiles = {"default_dirt.png"},
groups = {crumbly=3},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("multi_map_generators:luxore", {
description = "Lux Ore",
tiles = {"levels_luxore.png"},
paramtype = "light",
light_source = 14,
groups = {cracky=3},
sounds = default.node_sound_glass_defaults(),
})
-- Stuff
local floatper = math.pi / FLOATPER
@ -104,14 +77,14 @@ function mmgen_levels.generate(current_layer, vm, area, data, minp, maxp, offset
local oy1 = offset_maxp.y
local oy0 = offset_minp.y
local c_stone = minetest.get_content_id("default:stone")
local c_sand = minetest.get_content_id("default:sand")
local c_water = minetest.get_content_id("default:water_source")
local c_lava = minetest.get_content_id("default:lava_source")
local c_stone = minetest.get_content_id("mcl_core:stone")
local c_sand = minetest.get_content_id("mcl_core:sand")
local c_water = minetest.get_content_id("mcl_core:water_source")
local c_lava = minetest.get_content_id("mcl_core:lava_source")
local c_grass = minetest.get_content_id("multi_map_generators:grass")
local c_dirt = minetest.get_content_id("multi_map_generators:dirt")
local c_luxore = minetest.get_content_id("multi_map_generators:luxore")
local c_grass = minetest.get_content_id("mcl_core:dirt_with_grass")
local c_dirt = minetest.get_content_id("mcl_core:dirt")
local c_luxore = minetest.get_content_id("mcl_core:stone_with_diamond")
local sidelen = x1 - x0 + 1
local ystride = sidelen + 32

View File

@ -0,0 +1,49 @@
--minetest.register_on_mapgen_init(function(mgparams)
-- minetest.set_mapgen_params({mgname="singlenode", flags="nolight", flagmask="nolight"})
--end)
mmgen_mytest = {}
--multi_map.register_global_3dmap(
-- "terrain",
-- {offset=0, scale=1, spread={x=200, y=125, z=200}, seed=1235, octaves=5, persist=0.6}
--)
function mmgen_mytest.generate(current_layer, vm, a, data, minp, maxp, offset_minp, offset_maxp,arg,seed)
local t1 = os.clock()
local c_dirt = minetest.get_content_id("mcl_core:dirt")
local c_stone = minetest.get_content_id("mcl_core:stone")
local c_grass = minetest.get_content_id("mcl_core:dirt_with_grass")
local c_water = minetest.get_content_id("mcl_core:water_source")
local c_air = minetest.get_content_id("air")
if arg.stone then c_stone = minetest.get_content_id(arg.stone) end
if arg.dirt then c_dirt = minetest.get_content_id(arg.dirt) end
if arg.water then c_water = minetest.get_content_id(arg.water) end
if arg.grass then c_grass = minetest.get_content_id(arg.grass) end
if arg.air then c_air = minetest.get_content_id(arg.air) end
local sidelen = maxp.x - minp.x + 1
local nvals=multi_map.get_global_3dmap_flat("terrain", {x=sidelen, y=sidelen, z=sidelen}, {x=minp.x, y=minp.y, z=minp.z})
local ni = 1
for z = minp.z, maxp.z do
for y = minp.y, maxp.y do
for x = minp.x, maxp.x do
local yy=multi_map.get_offset_y(y)
if nvals[ni] - (yy - 25) / 55 > 0.5 then
local vi = a:index(x, y, z)
if yy < 1 then
data[vi] = c_stone
else
data[vi] = c_grass
end
elseif yy < 1 then
local vi = a:index(x, y, z)
data[vi] = c_water
end
ni = ni + 1
end
end
end
end

View File

@ -2,7 +2,7 @@ mmgen_simple = {}
function mmgen_simple.generate(current_layer, vm, area, vm_data, minp, maxp, offset_minp, offset_maxp, params)
local nodetype = "default:stone"
local nodetype = "mcl_core:stone"
local height = 0
if params and type(params) == "table" then

View File

@ -138,9 +138,9 @@ function mmgen_testauri.generate(current_layer, vm, area, vm_data, minp, maxp, o
end
if oy <= height then
vm_data[vi] = multi_map.node["default:stone"]
vm_data[vi] = multi_map.node["mcl_core:stone"]
elseif oy <= mmgen_testauri.water_height then
vm_data[vi] = multi_map.node["default:water_source"]
vm_data[vi] = multi_map.node["mcl_core:water_source"]
end
-- Increment noise index.

View File

@ -1,3 +1,3 @@
name = multi_map_generators
description = example mapgens for multi_map
depends = default, multi_map_core
depends = mcl_core, multi_map_core