Closed youyou-128 closed 6 months ago
As per the wiki, in order to use player-context values, you will need to specify that your subroutine is called from player contexts:
The parameters and variables defined in subroutines will be global by default. To change it to be player variables, add the playervar keyword before the subroutine rule name.
playervar Number asd; void test1() playervar "test" { SmallMessage(EventPlayer(), "test"); EventPlayer().asd = 1; }
If you use the event player in the async subroutine called by the global rule, it looks like this:
You will encounter compiler errors:
The function 'test1' calls a restricted value of type 'Event Player'.
But in fact, it works in the game In the game, when EventPlayer().asd = 1 is executed, it actually modifies the variable value in the global variable that has the same index as asd. In my example, the index ofqwer
is 9, so he will modify the global variable with index 9, which isinput
In other words, the context object used by the subroutine in the global rule is Gloal