How do I reset some global variables?

0 favourites
  • 6 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • 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!

  • 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...

  • 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..

  • Thank you for your solutions. I´ll work around them!!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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...

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)