Streaming Hub 0.1

Math: Number Operate

Calculate a numeric expression and write its result to a variable or runtime path.

Alpha

How to configure the step

Add Math: Number Operate to a sequence. Enter the formula in Expression and the destination in Target Path. The destination normally starts with vars. for a project variable that survives later runs, or runtime. for a value used only by the current run.

Expressions may contain number literals, values from paths in braces, arithmetic operators, parentheses, and the functions documented below. The result must be a finite number; otherwise the step is skipped and a warning is written to the log.

Values and paths

  • Use a literal directly: 42.5.
  • Insert a value from the current context in braces: {event.amount}, {vars.counter}, or {runtime.score}.
  • Combine them: {vars.counter} + 1. With vars.counter = 4, the result is 5.
  • Store the result in a writable path, for example vars.counter or runtime.donation.percent.

Arithmetic operators

  • Addition (+): {vars.counter} + 1 increments a counter.
  • Subtraction (-): {event.amount} - {vars.discount} calculates a remaining amount.
  • Unary + and - preserve or reverse a number's sign. Example: -{runtime.offset} reverses an offset.
  • Multiplication (*): {event.amount} * 100 converts a fraction to a percentage.
  • Division (/): {vars.total} / {vars.count} calculates an average. Do not divide by zero.
  • Remainder (%): {vars.index} % 2 returns 0 for even values and 1 for odd values.
  • Parentheses control order: ({event.amount} - {vars.discount}) * 1.2 applies tax after the discount.

min and max

  • min(a, b, ...) returns the smallest supplied number. Example: min({event.amount}, 100) caps a value at 100.
  • max(a, b, ...) returns the largest supplied number. Example: max({vars.lives} - 1, 0) prevents a counter from going below zero.
  • They accept more than two values: max({runtime.a}, {runtime.b}, {runtime.c}) selects the largest score.

Rounding functions

  • round(value) rounds to a whole number, with halves rounded away from zero: round(2.5) is 3 and round(-2.5) is -3.
  • round(value, digits) keeps from 0 to 15 decimal places. Example: round({event.amount} * 100, 2) produces a percentage such as 37.46.
  • floor(value) rounds down toward negative infinity. Example: floor(3.9) is 3; floor(-3.1) is -4. Use it for a zero-based page or tier index.
  • ceil(value) rounds up toward positive infinity. Example: ceil({runtime.elapsedSeconds} / 60) counts started minutes.

Absolute value

  • abs(value) removes the sign. Example: abs({event.amount} - {vars.target}) gives the distance from a target.
  • It can be nested with other functions: round(abs({runtime.temperature} - 21.5), 1) returns the absolute deviation rounded to one decimal place.

Complete examples

  • Increment a project counter: Expression = {vars.counter} + 1; Target Path = vars.counter.
  • Keep a volume in the 0–100 range: Expression = min(max({runtime.requestedVolume}, 0), 100); Target Path = runtime.volume.
  • Show a donation progress percentage: Expression = round({vars.raised} / {vars.goal} * 100, 2); Target Path = runtime.progressPercent. Make sure vars.goal is not zero.
  • Alternate two scenes: Expression = {vars.sceneIndex} % 2; Target Path = runtime.sceneSlot.
  • Calculate a non-negative remaining number: Expression = max({vars.goal} - {vars.current}, 0); Target Path = runtime.remaining.

Troubleshooting

Use a period as the decimal separator. Check that every referenced path contains a number or numeric text when the step runs. Missing values, unsupported functions, malformed formulas, division by zero, and NaN or infinity do not produce a result; inspect the Math warnings in Logs and test the automation with representative data.