Calling RestartGame() but keeping a variable (SOLVED)

Started by Akumayo, Tue 21/02/2006 00:59:40

Previous topic - Next topic

Akumayo

Is it possible?Ã,  It would be about 300x more convenient for me if I could call RestartGame(); and somehow keep one of the variables I've defined.Ã,  Manually resetting everything will take ages, even with a defined function.Ã,  Is there an easier way to do this?

EDIT:
I just thought of this, a solution to my problem, but I'll still need help to do it.Ã,  How would I store the contents of the variable into an external file, and then upload the contents back after the game is finished resetting?
"Power is not a means - it is an end."

Ashen

Use the File Functions, or RickJ's IniFile Module (that might be overkill for the relatively simple need you have, but it should demostrait usng the functions).
I know what you're thinking ... Don't think that.

Akumayo

Thanks Ashen, I'm looking into the file functions.  Perhaps they will serve the purpose, for now I realize that I need much more than just that one variable to be saved.  Perhaps ten or twenty will have to be saved to disk.  The player can't edit the files can they?
"Power is not a means - it is an end."

Ashen

In theory, I think they can as it's essentially just a standard text file. However, is this really important, if you're just passing the data pretty much straight back into the game?

You can take precautions - from saving the file with an unusual extention so they can't easily get into it, to using the EncryptedFile module.
I know what you're thinking ... Don't think that.

Akumayo

Hrm... It is being fed directly back into the game, but if the player is crafty, I think they could get around and change the values.  Perhaps there is another way to pass the variables on after a restart?
"Power is not a means - it is an end."

RickJ

I have a similar need, to have a couple of state variables survie a restore game operation.  It's discussed in the following thread:

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=25193.0

The easiest workaround at the moment is to just dump data into a file and then read it back using the on_event() inteaction in the global script or in a module.   The resulting file has sort of a binary format and so isn't easily edited by the casual user.   You would need to use a hex editor of some kind to hack it, especially if the data was other than strings.   IMHO, I wouldn't worry about it.   



Akumayo

#6
Quote from: RickJ on Wed 22/02/2006 00:56:54
The easiest workaround at the moment is to just dump data into a file and then read it back using the on_event() inteaction in the global script or in a module.Ã, 

Could you describe how exactly I would go about doing that?Ã,  I'm completely new to AGS's I/O commands.Ã,  I'm not even sure how I would set up the file to dump contents into, much less how to read it back.Ã,  I'm studying what the manual has to offer, but it doesn't really make much sense to me.Ã,  I'm trying though...

EDIT:  A new approach to the problem led me to a solution.  By converting all my local variables to global variables, and calling ResetRoom(); for all rooms from the starting room, then changing ResetGame() lines to lines that alter the character room to that of the ResetRoom(); room, I succesfully reset the game, but kept all the variables.  (I'm very glad my game is room based now  ;D )

Thanks for the help anyway guys!
"Power is not a means - it is an end."

SMF spam blocked by CleanTalk