Looking for a save/load function
-
If you are using pianofire's persistent code, you can just do it like this:
To load stuff in your init function:
store = [] if loadStore() then playerStore.PGold = getValue("PGold") playerStore.keys = getValue("keys") playerStore.life = getValue("life") playerStore.x = getValue("x") playerStore.y = getValue("y") endif
Note that the loadStore() function returns false if there was no persistent data already saved, so you will then need to populate playerStore with some default values. Also note that store needs to be a global variable.
To save stuff whenever necessary:
setValue("PGold", playerStore.PGold, "int") setValue("keys", playerStore.keys, "int") setValue("life", playerStore.life, "int") setValue("x", playerStore.x, "int") setValue("y", playerStore.y, "int") saveStore()
-
@vinicity cheers I'l have another bash at it, always overwhelming trying something new but i feel i can handle that
as long as i can get one working then the rest will follow -
I do it in my car race game one value at a time, you can have a look.
-
Defo use pianofire’s code for this. It makes it so easy!
-
@Ithendall cheers, nice to have a game as reference plus i'v not managed to play it yet been busy in a coding frenzy haha
-
Well, it is still in progress, not finished :)
-
For lists of stuff like that, I do (for example)
For x = 1 to 10 loop SetValue(”myList[”+str(x)+”]”,myList[x],”int”) repeat``` ..or something like that. See how it works?
-
Nevermind i think i'v figured it :)
-
I was just giving another example for if you have an array of structs, or a highscore list or something. It wasn’t aimed at your question there. Good you got it sorted though :)
-
@toxibunny yeah i got that, i'm fine with this for now though thanks man