Skip to content

Call Function

Call Function

Executes a reusable function defined in the database, passing input and output switches and variables to exchange data.

Properties

System

Name Explanation Type
Function The function to call from the database. Number
Input Switches The switch values to pass as input parameters to the function. Switch or Value
Input Variables The variable values to pass as input parameters to the function. Variable or Value
Output Switches The switch references that receive output values from the function after it executes. Switch or Value
Output Variables The variable references that receive output values from the function after it executes. Variable or Value

Examples

Call a Function by Index

Calls function 0 from the database with no input or output parameters.

call_function(0);
{"Data":{"FunctionIndex":0,"InputSwitches":[],"InputVariables":[],"OutputSwitches":[],"OutputVariables":[],"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.System.CallFunctionCommand"}

Call a Function with Input and Output Variables

Calls function 1, passing two global variables as input and receiving one global variable as output.

call_function(1, iv: [$gv[0], $gv[1]], ov: [$gv[2]]);
{"Data":{"FunctionIndex":1,"InputSwitches":[],"InputVariables":[{"IsGlobalVariable":true,"IsLocalVariable":false,"IsValue":false,"Value":"0","VariableIndex":0,"Metadata":null},{"IsGlobalVariable":true,"IsLocalVariable":false,"IsValue":false,"Value":"0","VariableIndex":1,"Metadata":null}],"OutputSwitches":[],"OutputVariables":[{"IsGlobalVariable":true,"IsLocalVariable":false,"IsValue":false,"Value":"0","VariableIndex":2,"Metadata":null}],"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.System.CallFunctionCommand"}

Call a Function with Input Switches

Calls function 2, passing a global switch as input.

call_function(2, is: [$gs[0]]);
{"Data":{"FunctionIndex":2,"InputSwitches":[{"IsGlobalSwitch":true,"IsLocalSwitch":false,"IsValue":false,"Value":false,"SwitchIndex":0,"Metadata":null}],"InputVariables":[],"OutputSwitches":[],"OutputVariables":[],"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.System.CallFunctionCommand"}