Having a very weird error. Short answer is I think two arrays are actually pointers to the same array. Long explanation follows.
Two arrays (on two container objects, player_frame
and enemy_frame
) are initialized as such:
set player_frame.conditions (new Array)
set player_frame.persistent_conditions (new Array)
[...]
set enemy_frame.conditions (new Array)
set enemy_frame.persistent_conditions (new Array)
To add conditions to these, I use two setter
functions:
set_persistent_condition target condition:
if (== $target "player_frame"):
push $player_frame.persistent_conditions $condition
elseif (== $target "enemy_frame"):
push $enemy_frame.persistent_conditions $condition
else:
"Error in set persistent condition, target is %{$target}, condition is %{$condition}"
run update_hud
set_condition target condition:
if (== $target "player_frame"):
push $player_frame.conditions $condition
elseif (== $target "enemy_frame"):
push $enemy_frame.conditions $condition
else:
"Error in set condition, target is %{$target}, condition is %{$condition}"
run update_hud
Fairly straightforward! So to my confusion, I found that using set_condition
as such:
if (== $initiator "enemy_frame"):
run set_condition "enemy_frame" Resilient
else:
run set_condition "player_frame" Resilient
set the condition for both arrays!
Using debug statements I’ve determined that it never hits set_persistent_condition
, this all goes through set_condition
only.
So I’m wondering, is there any chance that both of those arrays are somehow being designated as pointers to the same array? If so, how do we avoid this?