-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Attempting to use Chase [Global / Player] Variable [At Rate / Over Time] (and, I suspect, other actions that have to do with variables not managed by OWScript) will cause OWScript to generate invalid Workshop code. The problem is that all variables in OWScript are just values in an array, but you cannot Chase a value in an array. You can only Chase an actual variable.
Consider the following simple example:
Rule "ez test"
Event
Event_Type: On Global
Actions
a = 5
Chase Global Variable At Rate
Variable: a
Destination: 0
Rate: 1
Reevaluation: Destination And Rate
That results in this:
rule("Generated by https://github.com/adapap/OWScript") { Event { Ongoing - Global; }}
rule("ez test") {
Event {
Ongoing - Global;
}
Actions {
Set Global Variable At Index(A, 0, 5);
Chase Global Variable At Rate(Value In Array(Global Variable(A), 0), 0, 1, Destination And Rate);
}
}
Attempting to paste this into the Workshop will give you this error:
Error: Expected ',' after 'Rate(' on line 8
And yet it will happily accept this small (and illogical) change:
rule("Generated by https://github.com/adapap/OWScript") { Event { Ongoing - Global; }}
rule("ez test") {
Event {
Ongoing - Global;
}
Actions {
Set Global Variable At Index(A, 0, 5);
Chase Global Variable At Rate(A, 0, 1, Destination And Rate);
}
}
Additionally, I don't think there is any simple workaround for this within OWScript, since any attempt to indicate an actual Workshop variable gets replaced by the OWScript variable system. For me to work around this, I would need to basically comb through OWScript's output every time I need to do something that involves chasing variables.
I'm not sure how this can be fixed since using an array for the variables is such a core feature of OWScript, but in any case, it would help if there was a way to include raw Workshop code in the OWScript code (kind of like a comment, but instead of being completely ignored, it's simply left in the output as it is). That would allow the user to create temporary workarounds for situations like this without having to comb through the output themselves.