Body, Mind & Soul — API Reference
    Preparing search index...

    Function evaluateModifierFormula

    • Evaluate a modifier formula string to a number (floored by default). The formula can contain:

      • Arithmetic operators: +, -, *, /
      • Parentheses for grouping
      • Functions: floor(), ceil(), round(), min(), max(), abs()
      • Variable tokens: {numStacks}, {str}, {self.foo}, etc. (resolved via context/actor)

      By default, the result is floored to an integer before returning. This behavior can be controlled via the options parameter.

      Parameters

      • formula: string

        The formula string (e.g., "0.5 * {numStacks}", "10 + floor({str}/2)")

      • Optionalcontext: object = {}

        Context object with token values (e.g., { numStacks: 3 })

      • Optionalactor: any = null

        Optional actor for attribute/vector token resolution

      • Optionaloptions: { floor?: boolean } = {}

        Configuration options

        • Optionalfloor?: boolean

          Whether to floor the result to an integer

      Returns number

      The result, optionally floored

      If the formula is invalid or evaluation fails