Learn how to create a function that can be repeatedly call, reuse or change behavior based on input parameters

Declare Function
Declare Function

To create or declare a Function use . You need 3 things:

  • Identifier: The function name which is used to... identify the function.
  • Input Parameters: Optional parameters. This acts exactly like a variable except its value is set when we call our Function.
  • Body: The things that run when this Function is called. The body accepts the same action as Main Group: Click, Swipe, Play Record, Image Detection, etc...

By default, when declare new function. The system automatically generate the name using the following format: f_ + current time in miliseconds. You can change it using the pen icon.

Function name follow the same rules as Variable.

It's recommended to name your Function with a meaning like doBattle, fightBoss, getHitByATruckToIsekai, etc...

Input Parameters

You can add optional parameters to a Function.

Anything in this Function can then use them like any Variable.

We "input" these parameters whenever we call our Function. So read on to the Call a Function section.

Call a Function
Call a Function

You can call a Function by using .

You can "input" parameters here. Now the parameters that we declare in the Function will be set to those values.

There's a convenient Repeat parameter you can change to call this Function repeatedly.

Return from Function
Call a Function

Using the action to return from a function

You can enter a value to return. Leave empty to return null

Code Equivalent

    //Declare our function
    fun add(a, b) {
        return a + b

    //call it
    add(1, 1) //3

© 2024 - Macrorify by KoK-CODE