1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00
RedMew/map_gen/maps/danger_ores/modules/dense_patches.lua

20 lines
661 B
Lua
Raw Normal View History

2020-09-02 13:26:19 +02:00
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