Learn how to create a function that can be repeatedly call, reuse or change behavior based on input parameters
To create or declare a Function
use . You need 3 things:
Function
.
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...
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.
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.
Using the action to return from a function
You can enter a value
to return. Leave empty to return null
//Declare our function
fun add(a, b) {
return a + b
}
//call it
add(1, 1) //3
© 2024 - Macrorify by KoK-CODE