mcl_multi_map/multi_map_generators/mmgen_mytest.lua

43 lines
1.5 KiB
Lua

mmgen_mytest = {}
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_stone
end
elseif yy < 1 then
local vi = a:index(x, y, z)
data[vi] = c_water
end
ni = ni + 1
end
end
end
end