Main question:
For global variable x and w = x.y.z (or w = x.y[z]), how can I edit w so that future references to x.y.z (or x.y[z]) (from different scripts, etc) will reflect the updated w?
Explanation:
As a corrolary to the previous post, I'm now trying this method:
// if actor.dialogue[stringId] is true, then the actor has said the line corresponding to stringId.
// in the following code, "this" refers to the actor who's speaking
var string_state = this.dialogue; // because wme doesn't like this.dialogue[stringId]
method TalkOnce(stringId) {
var string_state = this.dialogue;
if (!string_state[stringId]) {
string_state[stringId] = true;
this.Talk(stringId);
}
}
However, even though I'm setting actor.dialogue[stringId] to true, the next time I call the method, actor.dialogue[stringId] has reverted to its previous null value. I suspect this is a pass-by-reference/pass-by-value problem. Namely, when I update string_state, I'm updating a copy of actor.dialogue (pass by value) rather than the actual actor.dialogue (pass by reference). Is this true? If so...
For global variable x and w = x.y.z (or w = x.y[z]), how can I edit w so that future references to x.y.z (or x.y[z]) (from different scripts, etc) will reflect the updated w?
Thanks,
Greg