1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-16 10:19:27 +02:00
RedMew/map_gen/maps/danger_ores/modules/dense_patches.lua
2021-01-02 23:40:30 +00:00

20 lines
663 B
Lua

local Perlin = require 'map_gen.shared.perlin_noise'
local seed_provider = require 'map_gen.maps.danger_ores.modules.seed_provider'
local perlin_noise = Perlin.noise
return function(config)
local scale = config.dense_patches_scale or (1 / 48)
local threshold = config.dense_patches_threshold or 0.5
local multiplier = config.dense_patches_multiplier or 50
local seed = config.dense_patches_seed or seed_provider()
return function(x, y, entity)
x, y = x * scale, y * scale
local noise = perlin_noise(x, y, seed)
if noise > threshold then
entity.amount = entity.amount * multiplier
end
end
end