Sorry for bad English. I try to describe my problem.
I make a sign-up page for my game and set a data at global singleton and save that when player start game at first time.
var user = {
name = null,
money = 1000,
etc
{
I make a remove button for delete data, If the player want to start new game again.
func user_remove_data():
var dir = Directory.new()
dir.remove(_global.PATH_USER)
Everything is OK. But my problem is:
- Player sign-up (write name).
- Save data and start playing.
- For example buy something and money become to 700.
- Come back to sign-up and remove name (game data)
- Write another name and start new game
- Money is NOT 1000, money is 700.
I add a for loop to func user_remove_data()
for reset data
for data in _global.user:
if data == 'name':
_global.user[data] = null
elif data == 'money':
_global.user[data] = 1000
I want to know that is there a better way to reset data at memory or my way is okey?