Reaper_Man, on 22 September 2020 - 08:16 AM, said:
Say I have ACTOR1 and want to check if ACTOR2 has a per-actor gamevar set to a certain value.
How would I read (or write) another actor's per-actor gamevar? This seems simple and I'm sure I'm overlooking something obvious.
It is simple, but you have to have the sprite ID number of the other actor in a gamevar first. That's the only part that can be tricky, depending on the context. But let's say you have done that already, by using findnearactor or by searching sprites via a loop or whatever.
Assume that "SPRITE" is a var that is set to the ID of the other sprite, and "VAR1" is a per-actor var. Then, in the code of an actor, you could write:
getactorvar[SPRITE].VAR1 VAR1
The above line would copy the value of VAR1 from the sprite SPRITE to the VAR1 in the current sprite (THISACTOR).
setactorvar[SPRITE].VAR1 VAR1
That would write the current copy of VAR1 in THISACTOR to the copy of that var in SPRITE
You can also abbreviate those commands to getav and setav