Reset global variables? (Possibly more)

For questions about using Classic.

Post » Thu Sep 29, 2011 5:56 pm

Hello everybody,

I am new to the whole construct-thing but I'm having loads of fun making my game and have already had quite some succes doing so.

However now I can't seem to find an option to reset gvars. What i basically want to do:

Player's spaceship dies once its gvar 'Shields' reches zero or below. Game switches to game over screen, now when I press the 'Resume' button I'd like the gvar 'SHields' to be reset to its initial value. Is there a way to do this?

And if there is: Is there a way to alter a gvar's default value too?

Situation: Starting Shield gvar is 4. Player buys upgrade for his shields, so gvar should be defaulted to 5 and after game over it needs to reset to 5 as opposed to 4 now.

I hope people can decipher what I mean.

Thanks in advance for any help!
B
2
G
1
Posts: 2
Reputation: 454

Post » Thu Sep 29, 2011 10:36 pm

Global variables remain the same between layouts, so if it goes up to 5 it will stay that way as long as the game is open, or you use a "Set global variable" action to change it.

However, the default value only applys when the program first starts. So no, chaning the default value of a global variable is not possible.

You could just try having another global variable called "defaultshield" and then on the start of layout set "shield" to "defaultshield". Then you just increase defaultshield to 5 as well as shield.Jayjay2011-09-29 22:37:37
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Fri Sep 30, 2011 3:41 pm

Thanks alot. That solution seems simple but it works perfectly. Guess sometimes you don't see the most practical things too quickly.
B
2
G
1
Posts: 2
Reputation: 454

Post » Sat Oct 01, 2011 1:29 am

[QUOTE=Xenonic] Thanks alot. That solution seems simple but it works perfectly. Guess sometimes you don't see the most practical things too quickly. [/QUOTE]

No problem, glad it's working out
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests