Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

math.where (procNode)

Choose between two values by a condition: a where cond is not 0, b where it is.

The where operation of the authoring surface, called through the Luau node on proc.fieldc.operators. Operands are numbers, vectors, Columns or Fields. When every operand is a plain number or vector the answer is the plain result, folded where the node cooks; otherwise the answer is a Field: a template over its operands that whatever reads it evaluates in one dispatch together with the chain around it. Nothing dispatches for this node alone. Over numbers and animated values the answer is an animated value: the operation at every time.

The node takes a, b, cond in that order, so a positional call is g.math.where(a, b, cond); the authoring surface's g.where(cond, a, b) takes the condition first and records this node. The condition reads its first component, and the answer is as wide as the wider of a and b.

Inputs

  • a (Value, default 0). The value taken where the condition holds.
  • b (Value, default 0). The value taken where it does not.
  • cond (Value, default 0). The condition: a number, 0 for false.

Outputs

  • value. a or b, per element.
local value = g.math.where({ a = 1, b = 2, cond = 0 }) -- 2