Skip to content

Evaluate Formula

Evaluate Formula

Evaluates a mathematical expression and stores the result in a Variable.

Properties

System

Name Explanation Type
Floating Point When enabled, the formula result will be stored as a floating point (decimal) number instead of an integer. Toggle
Formula The mathematical expression to evaluate. Formula
Integer When enabled, the formula result will be truncated to a whole number (integer). Toggle
Target The variable where the evaluated formula result will be stored. Variable or Value

Examples

Add Two Variables and Store the Result in Global Variable 0

This evaluates the sum of Global Variable 1 and Global Variable 2, storing the integer result in Global Variable 0.

$gv[0] = eval($gv[1] + $gv[2]);
{"Data":{"Formula":"global(1) + global(2)","IsFloatingPoint":false,"Target":{"IsGlobalVariable":true,"IsLocalVariable":false,"IsValue":false,"Value":"","VariableIndex":0,"Metadata":null},"Index":0,"IndexEnd":null,"IsLocal":0,"IsOperandReference":0,"IsReference":0,"OperandGlobalIndex":null,"OperandLocalIndex":null,"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Data.EvaluateFormulaCommand"}

Evaluate the Maximum of a Variable and a Fixed Value

This evaluates the maximum of Global Variable 1 and 10, storing the integer result in Global Variable 0.

$gv[0] = eval(max($gv[1], 10));
{"Data":{"Formula":"max(global(1), 10)","IsFloatingPoint":false,"Target":{"IsGlobalVariable":true,"IsLocalVariable":false,"IsValue":false,"Value":"","VariableIndex":0,"Metadata":null},"Index":0,"IndexEnd":null,"IsLocal":0,"IsOperandReference":0,"IsReference":0,"OperandGlobalIndex":null,"OperandLocalIndex":null,"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Data.EvaluateFormulaCommand"}

Evaluate a Formula with Floating Point Result

This evaluates the expression using Global Variable 1, storing the result as a floating point number in Global Variable 0.

$gv[0] = eval($gv[1] * 2 + 1, floating_point);
{"Data":{"Formula":"global(1) * 2 + 1","IsFloatingPoint":true,"Target":{"IsGlobalVariable":true,"IsLocalVariable":false,"IsValue":false,"Value":"","VariableIndex":0,"Metadata":null},"Index":0,"IndexEnd":null,"IsLocal":0,"IsOperandReference":0,"IsReference":0,"OperandGlobalIndex":null,"OperandLocalIndex":null,"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Data.EvaluateFormulaCommand"}