1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-08 00:39:30 +02:00
ComfyFactorio/maps/stone_maze/noise.lua

21 lines
637 B
Lua
Raw Normal View History

2019-08-06 23:54:07 +02:00
local simplex_noise = require "utils.simplex_noise".d2
local noises = {
["trees_01"] = {{modifier = 0.03, weight = 1}, {modifier = 0.05, weight = 0.3}, {modifier = 0.1, weight = 0.05}},
["scrap_01"] = {{modifier = 0.04, weight = 1}, {modifier = 0.06, weight = 0.3}, {modifier = 0.08, weight = 0.1}}
}
local function get_noise(name, pos, seed)
local noise = 0
local x = pos.x
local y = pos.y
if not x then x = pos[1] end
if not y then y = pos[2] end
for _, n in pairs(noises[name]) do
noise = noise + simplex_noise(x * n.modifier, y * n.modifier, seed) * n.weight
seed = seed + 10000
end
return noise
end
return get_noise