Closed netux closed 5 years ago
This is actually a subset of a larger issue. Once a type is defined for a variable, there is no way to change it as the variable is found in the scope table without checking if the type has changed. This way, you cannot recast a const
type into a pvar
type. I guess my question would be should we allow this behavior if changing targets for player variables?
I haven't looked much into the codebase. Can't there be an exception for constants? as in, constants being a completely different type with separated code from gvars and pvars.
🎉 Almost!
The pvar target now updates correctly, but only when you use the @
. If, for example, you have
pvar test = 1
pvar test@Cur Elem = 2
pvar test = 3
the third line actually works like pvar hello@Cur Elem = 3
, not pvar hello@Event Player = 3
Just tested again and it seems to be working fine 👍
Problem
Declaring a pvar who's "target" is, for example, Event Player sets the "target" of the variable to that indefinitely, even if we try to use
pvar variable@new_target
Examples
On that script, we set the pvar of Event Player to the closest player to the reticle of that player, then we try setting the same pvar on the other player (now stored in
other_player
) to the Event Player, effectively "linking" them.Currently, OWScript traspiles that last line to:
instead of
Another, real world, example would be the following
The first two rules transpile correctly, but the last rule ...
... uses
Event Player
instead ofCurrent Array Element
Side note
This script causes an infinite loop: