NoiseFunction parameter defaults
Posted: Sat Jan 10, 2026 6:26 am
I am currently trying to implement a new MapGen Setting and have re-implemented some old 1.0 mod code.
One question that popped up for me is how can one set a default value for NoiseFunction parameters.
The parameters attribute is a string only array, so there is no possibility of param=default.
When looking at multioctave_noise (which I would like to wrap, then some of the parameters have default values. How do I need to define my noise function to achieve the same result?
Here is a sample definition to show off what I want to achieve
One question that popped up for me is how can one set a default value for NoiseFunction parameters.
The parameters attribute is a string only array, so there is no possibility of param=default.
When looking at multioctave_noise (which I would like to wrap, then some of the parameters have default values. How do I need to define my noise function to achieve the same result?
Here is a sample definition to show off what I want to achieve
Code: Select all
data:extend{
{
type = "noise-function",
name = "multi_octave_wrapper",
parameters = {
"x",
"y",
"persistence",
"octaves",
"seed0",
"seed1",
"input_scale_base" = 1, -- should be optional
"output_scale _base" = 1}, -- should be optional
expression = "multioctave_noise{\z
x=x,\z
y=y,\z
persistence=persistence,\z
seed0=seed0,\z
seed1=seed1,\z
octaves=octaves,\z
input_scale=input_scale,\z
output_scale=output_scale}",
local_expressions = {
largest_octave_scale = "(2 ^ (octaves))",
input_scale = "input_scale_base / largest_octave_scale",
output_scale = "input_scale_base * largest_octave_scale"
}
},