How do I reset some global variables?

Get help using Construct 2

Post » Thu Oct 16, 2014 5:13 pm

I´d would like to know if there is a way to reset all the global variables in a game except some of them. I have 20 and I need to reset 17, and the only way that I know to do it is manually.

Any other ideas?

Thank you! ;)
B
6
S
1
Posts: 22
Reputation: 483

Post » Thu Oct 16, 2014 7:34 pm

All I have seen is the reset all option.
You could write a function that does it and call that when they need to be reset, or put the ones to reset in their own group manually resetting and then activate and deactivate it to reset them all at once...
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 635
Reputation: 9,331

Post » Thu Oct 16, 2014 9:06 pm

jorj0 wrote:I´d would like to know if there is a way to reset all the global variables in a game except some of them. I have 20 and I need to reset 17, and the only way that I know to do it is manually.

Any other ideas?

Thank you! ;)


C2 can't read your mind ;) But yea you can get creative, like ^^^
How about this... copy to local vars, the 3 you want, reset all, then re-copy back from temp :)
Or, put the vars in a dummy global object as instance vars..
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Oct 17, 2014 9:08 am

Thank you for your solutions. I´ll work around them!! ;)
B
6
S
1
Posts: 22
Reputation: 483

Post » Fri Oct 17, 2014 10:11 am

I still think you could say make 3 more variables called the three names +temp (like Score_temp) and put them all 3 in a group called say "Temp", then right before you wipe all variables make the Score_temp = Score, etc, etc. and then deactivate group "Temp". They "should" stay safe and unwiped while deactivated, then after reset activate "Temp" and set Score to Score_temp, etc, etc...

Or like codah suggested.. make an object and set 3 instance variables in it then just set them to your globals before wipe and reset globals from the object after...
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 635
Reputation: 9,331

Post » Fri Oct 17, 2014 10:51 am

To be honest you should be examining why you need 20 global variables and that you have to reset 17 of them like this. Maybe rethink your design.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to How do I....?

Who is online

Users browsing this forum: Clark Thy Lord, timoteomorelli and 1 guest