Overwatch-Script-To-Workshop
Overwatch-Script-To-Workshop copied to clipboard
Calling methods inside conditions will not refresh the argument variables before calling
If you call a custom method from a condition, the condition will be evaluated before the body of the rule, which sets the required arguments variables
rule: "Example"
Event.OnDeath
if (IsGameInProgress())
if (Attacker() != Victim())
if (IsWinning(Attacker()))
{
// whatever
}
compiles to
rule("Example")
{
event
{
Player died;
All;
All;
}
conditions
{
Is Game In Progress == True;
Attacker != Victim;
Value In Array(Global Variable(Scores), Slot Of(Player Variable(Event Player, Player))) >= Subtract(Count Of(Global Variable(HeroList)), 1);
}
// Action count: 10
actions
{
Set Player Variable(Event Player, Player, Attacker);
// whatever
}
}
As such, this condition is evaluated incorrectly.
Sorry for the late response!
You can use in
parameters or macros so that the parameters are not set to a value.
// These do the exact same thing
// Macro
Boolean X(Number value): value + 2;
// Function
Boolean X(in Number value) {
// This will output correctly as long as nothing inside the method generates actions.
return value + 2;
}
OSTW will need to ensure that users don't generate actions in conditions