Allow us, workshop developers create functions, that we can call inside another rules/actions/conditions.
We have subroutines, but them is like an mixed between thread and functions.
Current limitations from an subroutine:
- Calling them asynchronously we cannot start more than one at once, so we cannot “spawn” multiple “threads”
- Subroutines, is a pseudo function that does not accept neither params, neither return value, so make difficulty to implement some macros to do little things.
Proposal is implemeting an new feature called functions.
- Will work like subroutines
- Must have an scope, so that function is global? or function that you can invoke in player based rule?
- Will accept params
- Will support return values.
- Can be used to set variables.
Global.A = MyFunc(Custom String("Some Arg"))
- Can be used in conditions.
conditions { MyBoolFunc(1, 3) == 4 }
- Limited to same subroutine count, we have an UI to define function, and their return value.
And extend subroutine features to add multiple async subroutines.
Code Example
variables
{
global:
0: myNum
player:
0: myInt
}
functions
{
IsSamePlayerVar
{
arguments:
0: thisPlayer
1: otherPlayer
}
}
rule("Declare function IsSamePlayerVar")
{
function
{
IsSamePlayerVar
}
Return(Compare(Local.thisPlayer.myInt, ==, Local.otherPlayer.myInt));
}
rule("On spawn room")
{
event { Ongoing Player; All; All; }
conditions
{
actions
{
}
}
- New value:
Local
, local variables is referred to function params. - New action:
Return
first param, accept an array or null for no return;
Return;
orReturn (Value);