Problem using triggers for handling global variables. (1 Viewer)

Rod

Content Creator
Joined
Jul 14, 2020
Hello!

I'm experiencing some strange behavior with the global variable scope provided by DialogActions.

What I want to do:
Use an object variable to pass state between different dialogues.

I'm using the REGISTERGLOBALS / LOADGLOBALS triggers for this.
What I experience with numeric properties is that they get converted to type string.

Attached is a stripped down example which can be used to reproduce the issue.
The main dialogue initializes a numeric 'game.progress' variable with value 0 and loads another dialogue (Scene1.txt).
Here I increment the progress variable by 5 and switch to Scene2.txt, which increments progress by 1 and switches back to Scene1.txt
Before switching scenes the value of the progress variable is printed to the screen.

What I expect to see is this sequence of progress values: 0, 5, 6, 11, 12, 17, ...
What I get is: 0, 05, 051, 0515, 05151, 051515, ...

So, there's string concatenation happening instead of addition.

DialogueChecker doesn't report any problems.

It would be awesome if someone could take a look at this and tell me what I'm doing wrong.
 

Attachments

TestGlobals.zip
1.3 KB · Views: 161

Slingerbult

Content Creator
Joined
Sep 15, 2012
I'm more used to the save namespace than the global, but the principle should be the same. I think you need to use a REGISTERGLOBALS trigger in the ""-line where you set the local value +1 or +5. That way, the newly set value of the local variable also gets updated in the global namespace for your other dialogues to use. Not sure why you're getting concatenation without though.
 

Rod

Content Creator
Joined
Jul 14, 2020
I'm more used to the save namespace than the global, but the principle should be the same. I think you need to use a REGISTERGLOBALS trigger in the ""-line where you set the local value +1 or +5. That way, the newly set value of the local variable also gets updated in the global namespace for your other dialogues to use. Not sure why you're getting concatenation without though.

Thanks for you suggestion.

I tried to use the REGISTERGLOBALS trigger as suggested, but to no avail.

However, I got it working by using a SETGLOBALS / LOADGLOBALS combo and omitting the dot after the variable name.

[SETGLOBALS_game.] // Doesn't work. Note the dot after 'game'

[SETGLOBALE_game] // Works like this.
 

Users who are viewing this thread

Top


Are you 18 or older?

This website requires you to be 18 years of age or older. Please verify your age to view the content, or click Exit to leave.