///
Call function overview

Call function

The Call function action allows you to execute a reusable from anywhere in your macro. Think of a function like a mini-macro that can accept inputs, do some work, and hand a result back to you.

First, you must create the function itself in the . Once added to your macro flow, simply tap the Call function action to open its configuration menu.

Function configured

Configuration & Parameters

When configuring a Call function action, you will define the following:

  • Target Function: The specific function you want to run.
  • Parameters: These input fields are dynamically generated based on the parameters you declared in the . For example, if you declared a baseDamage parameter, a text field for it will automatically appear here when you select the function. If you leave a parameter blank, the function will use its default value.
  • Save Return To Variable: Functions can send data back (like the X/Y coordinates of a found item), though a return value is NOT mandatory. Put a variable name here, and it will save the function's result directly into that variable so the rest of your macro can use it.
  • Loop Mode & Count: You can choose to loop the function call a specific number of times (Counted) or infinitely (Infinite).
  • Speed multiplier (×): Scales the delays and gestures inside this particular call, 2 runs it twice as fast, 0.5 at half speed. It applies to this call only, so the same function can run slowly in one place and quickly in another. Takes a %variable% if the right speed depends on something the macro worked out.

Advanced Function Behaviors

  • Recursive Calls: A function can call itself to perform recursion. Ensure a stopping condition is included to prevent an endless loop.
  • Automatic Variable: Even if you don't fill out the Save Return To Variable field, the result of the last called function is always temporarily available in the built-in variable %lastFunctionReturn%.

Code Equivalent

// Calling a macro function (created in the Functions tab) and saving its return value: let result = callFunction("Calculate Damage", { base: 50, multiplier: 2 }); // Calling a macro function without saving the return value: callFunction("Calculate Damage", { base: 100, multiplier: 1.5 }); // Standard GScript function call: let damage = calculateDamage(50, 2);