Factorio Prototype DocsVersion 1.1.100

NoiseExpression :: union Example code

Loaded as one of the noise expressions listed in this union, based on the value of the type key.

A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.

Noise expressions can be provided as table literals or built using functions in the built-in noise library. The built-in noise library allows writing much more concise code, so its usage will be shown in most examples for noise expressions.

noise.define_noise_function allows noise expressions to be defined using a shorthand that's a subset of Lua (see the example for details).

See here for a tutorial on authoring noise expressions.

Union members

NoiseVariable

Loaded when the type is "variable".

NoiseFunctionApplication

Loaded when the type is "function-application".

NoiseLiteralBoolean

Loaded when the type is "literal-boolean".

NoiseLiteralNumber

Loaded when the type is "literal-number".

NoiseLiteralString

Loaded when the type is "literal-string".

NoiseLiteralObject

Loaded when the type is "literal-object".

NoiseLiteralExpression

Loaded when the type is "literal-expression".

NoiseArrayConstruction

Loaded when the type is "array-construction".

NoiseProcedureDelimiter

Loaded when the type is "procedure-delimiter".

NoiseIfElseChain

Loaded when the type is "if-else-chain".

Examples

-- "noise" library required beforehand
expression = noise.define_noise_function(function(x, y, tile, map)
  return (x + y) / 1000
end)
expression = {
  type = "function-application",
  function_name = "divide",
  arguments = {
    {
      type = "function-application",
      function_name = "add",
      arguments = {
        {
          type = "variable",
          variable_name = "x"
        },
        {
          type = "variable",
          variable_name = "y"
        }
      }
    },
    {
      type = "literal-number",
      literal_value = 1000
    }
  }
}

Prototypes

Types