Move noise indicator into separate file

This commit is contained in:
kay27 2022-01-16 19:20:42 +04:00
parent fefa9c8b4f
commit 2cfca05186
5 changed files with 55 additions and 43 deletions

View File

@ -268,30 +268,6 @@ local function spawn_spikes_in_v6(p, nn, pr)
end
local function generate_structures(vm_context)
local levels = {
[-9] = "black",
[-8] = "brown",
[-7] = "brown",
[-6] = "gray",
[-5] = "gray",
[-4] = "red",
[-3] = "orange",
[-2] = "purple",
[-1] = "magenta",
[0] = "pink",
[1] = "yellow",
[2] = "green",
[3] = "lime",
[4] = "blue",
[5] = "cyan",
[6] = "light_blue",
[7] = "silver",
[8] = "silver",
[9] = "white",
}
-- local pr = PcgRandom(vm_context.blockseed)
local pr = PcgRandom(vm_context.chunkseed)
-- chunk_has_desert_struct = false
-- chunk_has_desert_temple = false
@ -304,20 +280,6 @@ local levels = {
local DIVLEN = 5
for x0 = minp.x, maxp.x, DIVLEN do for z0 = minp.z, maxp.z, DIVLEN do
-- Determine amount from perlin noise
local noise = perlin_structures:get_2d({x=x0, y=z0})
local amount
if noise < 0 then
amount = math_max(math_ceil(noise * 9), -9)
else
amount = math_min(math_floor(noise * 9), 9)
end
-- local amount = math_floor(perlin_structures:get_2d({x=x0, y=z0}) * 9)
local y1 = maxp.y - 9 + amount
for x1 = x0, x0 + DIVLEN - 1, 1 do for z1 = z0, z0 + DIVLEN - 1, 1 do
minetest.set_node({x=x1, y=y1, z=z1}, {name = "mcl_core:glass_"..levels[amount]})
end end
-- Find random positions based on this random
local p, ground_y, nn
for i = 0, 24 do

View File

@ -121,11 +121,12 @@ mcl_structures.register_structure({
deco_type = "simple",
place_on = node_list,
flags = "all_floors",
fill_ratio = 0.00003,
--fill_ratio = 0.00003,
fill_ratio = 0.003,
y_min = 3,
y_max = mcl_mapgen.overworld.max,
height = 1,
biomes = {
biomes = not mcl_mapgen.v6 and {
"ColdTaiga_beach",
"ColdTaiga_beach_water",
"Desert",
@ -146,6 +147,7 @@ mcl_structures.register_structure({
on_finished_chunk = function(minp, maxp, seed, vm_context, pos_list)
local a = seed % 14
local b = (math.floor(seed / 39) + 4) % 12
minetest.chat_send_all("seed=" .. tostring(seed) .. ", a=" .. tostring(a) .. ", b=" ..tostring(b))
if a ~= b then return end
local pos = pos_list[1]
if #pos_list > 1 then

View File

@ -17,6 +17,8 @@ local use_process_mapgen_chunk = false
local on_finished_block_callbacks = {}
local on_finished_chunk_callbacks = {}
mcl_structures.perlin_noise = minetest.get_perlin(329, 3, 0.6, 100)
function process_mapgen_block_lvm(vm_context)
local nodes = minetest.find_nodes_in_area(vm_context.minp, vm_context.maxp, {"group:struct"}, true)
for node_name, pos_list in pairs(nodes) do
@ -70,7 +72,7 @@ function mcl_structures.register_structure(def)
local decoration_id
if decoration then
minetest.register_node(':' .. name, {
drawtype = "airlike",
-- drawtype = "airlike",
sunlight_propagates = true,
pointable = false,
walkable = false,

View File

@ -0,0 +1,42 @@
local levels = {
[-9] = "black",
[-8] = "brown",
[-7] = "brown",
[-6] = "gray",
[-5] = "gray",
[-4] = "red",
[-3] = "orange",
[-2] = "purple",
[-1] = "magenta",
[0] = "pink",
[1] = "yellow",
[2] = "green",
[3] = "lime",
[4] = "blue",
[5] = "cyan",
[6] = "light_blue",
[7] = "silver",
[8] = "silver",
[9] = "white",
}
local math_min, math_max = math.min, math.max
local math_floor, math_ceil = math.floor, math.ceil
mcl_mapgen.register_mapgen(function(minp, maxp, seed, vm_context)
mcl_structures.perlin_noise = mcl_structures.perlin_noise or minetest.get_perlin(329, 3, 0.6, 100)
local perlin_noise = mcl_structures.perlin_noise
for x0 = minp.x, maxp.x do
for z0 = minp.z, maxp.z do
local current_noise_level = perlin_noise:get_2d({x=x0, y=z0})
local amount
if current_noise_level < 0 then
amount = math_max(math_ceil(current_noise_level * 9), -9)
else
amount = math_min(math_floor(current_noise_level * 9), 9)
end
local y0 = maxp.y - 9 + amount
minetest.set_node({x=x0, y=y0, z=z0}, {name = "mcl_core:glass_"..levels[amount]})
end
end
end, -1)

View File

@ -1,5 +1,9 @@
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
dofile(modpath .. "/desert_temple.lua")
dofile(modpath .. "/stronghold.lua")
if not mcl_mapgen.singlenode then
dofile(modpath .. "/desert_temple.lua")
dofile(modpath .. "/stronghold.lua")
dofile(modpath .. "/noise_indicator.lua")
end