[SOLVED] Global variable initialization

Hi all,
I want to give a value to a global variable once, and only once, at the begining of the game, not at the beginning of the scene because the hero will come back to the first scene many time.

More or les the algorythm :
the game start at scene 1 - Do 50 to global variable(life)
the player is in scene 2 and goes in scene 1 : do nothing with global variable(life)

I though about doing a scene 1 for begining and a scene 1 to come back, but the solution is not very nice… :blush:

Any idea ?

thanks :slight_smile:

You could use other variables to control that.

Like, assign an id # to the scenes and on the action where both scenes are changed do:

Do Variable(sceneid) to global variable Scene

In the beginning of your scenes, you could add:
Condition: global variable Scene = 1
Action: Do +50 to variable(life)

Condition: global variable Scene = 2
Action: Do + 0 to variable(life)

If you set variable(life) to = 0, I’m figuring it will die, which you don’t want.

Doing +0 simply doesn’t add any more.

I’ll try to explain more and get an example together later if needed as I have to go now.

2 Likes

yep !
the idea was good and will allowed me to give an id# to each scene… Just perfect.
Thanks a lot for the quick answer !

1 Like

Glad it worked out. :+1: You’re welcome :smiley:

2 Likes