Factorio Prototype DocsVersion 1.1.107

NoiseFunctionDistanceFromNearestPoint :: struct Example code

Computes the euclidean distance of the position {x, y} to all position listed in points and returns the shortest distance. The returned distance can be maximum_distance at most.

Properties

type :: "function-application"
function_name :: "distance-from-nearest-point"
arguments :: DistanceFromNearestPointArguments

Properties

type :: "function-application"

function_name :: "distance-from-nearest-point"

arguments :: DistanceFromNearestPointArguments

DistanceFromNearestPointArguments :: struct

Properties

maximum_distance :: ConstantNoiseNumber optional

Default: max double

Example

-- Shortest distance at the current {x, y} from the two given points, but at most 1000
local noise = require("noise")
local tne = noise.to_noise_expression
local positions = noise.make_point_list({{-100, -40}, {-50, -200}})

local shortest_distance =
{
  type = "function-application",
  function_name = "distance-from-nearest-point",
  arguments = {x = noise.var("x"), y = noise.var("y"), points = positions, maximum_distance = tne(1000)}
}
-- or with the noise lib
local also_shortest_distance = noise.function_application("distance-from-nearest-point", {x = noise.var("x"), y = noise.var("y"), points = positions, maximum_distance = 1000})

Prototypes

Types