Skip to content

Change Variable

Change Variable

Alters the value of a Variable, with support for ranges and Local or Global variables.

Targets

Name Explanation
Global / Local Targets a single Variable.
Global / Local Range Targets multiple contiguous Variables.
Global / Local Reference Targets a single Variable based on a Variable index.

Values

Name Explanation
Value Leverages a value, as a Number or String.
Local Leverages a single Local Variable.
Global Leverages a single Global Variables.
Random Leverages a random Number value, between a Minimum and Maximum.

Examples

Set Global Variable 3 to a Random Value Between 6 and 12

This sets Global Variable 3 to a random value between 6 and 12.

$gv[3] = random(6, 12);
{"Data":{"Operation":0,"RandomEnd":"12","RandomStart":"6","Value":"","Index":3,"IndexEnd":null,"IsLocal":0,"IsOperandReference":0,"IsReference":0,"OperandGlobalIndex":null,"OperandLocalIndex":null,"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Data.VariableCommand"}

Add 20 to Local Variables 0 through 6

This adds 20 to Local Variables 0 through 6.

$lv[0:6] += 20;
{"Data":{"Operation":1,"RandomEnd":null,"RandomStart":null,"Value":"20","Index":0,"IndexEnd":6,"IsLocal":1,"IsOperandReference":0,"IsReference":0,"OperandGlobalIndex":null,"OperandLocalIndex":null,"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Data.VariableCommand"}

Subtract 1 from Global Variable by Reference, Based on Global Variable 0

This subtracts 1 from a Global Variable, with an index specified by Global Variable 0.

$ref_gv[0] -= 1;
{"Data":{"Operation":2,"RandomEnd":null,"RandomStart":null,"Value":"1","Index":0,"IndexEnd":null,"IsLocal":0,"IsOperandReference":0,"IsReference":1,"OperandGlobalIndex":null,"OperandLocalIndex":null,"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Data.VariableCommand"}

Multiply Global Variable by Reference, Based on Global Variable 0, by 5

This multiplies the value of a Global Variable, with an index specified by Global Variable 0, by 5.

$ref_gv[0] *= 5;
{"Data":{"Operation":3,"RandomEnd":null,"RandomStart":null,"Value":"5","Index":0,"IndexEnd":null,"IsLocal":0,"IsOperandReference":0,"IsReference":1,"OperandGlobalIndex":null,"OperandLocalIndex":null,"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Data.VariableCommand"}

Set Local Variable 0 to the Value of Global Variable 5

This sets Local Variable 0 to the value in Global Variable 5.

$lv[0] = $gv[5];
{"Data":{"Operation":0,"RandomEnd":"","RandomStart":"","Value":"","Index":0,"IndexEnd":null,"IsLocal":1,"IsOperandReference":0,"IsReference":0,"OperandGlobalIndex":5,"OperandLocalIndex":null,"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Data.VariableCommand"}