Jump to content

Saving and loading progress?


irei1as

Recommended Posts

Let's say I have a set of variables I want to save for later called "$score::XXX" (XXX being different variables).


For saving that data I'm doing right now:

export("$score*","score"); //create uncompiled score file
compile("./score",true);   //create compiled score.dso
fileDelete("./score");     //deletes the intermediate uncompiled file

 

And then when I restart the game and I want to load the scores I do:

(pseudocode)

if(isFile("score.dso"))
exec("score.dso");
else
save not found, show warning can't load;

 


... but I'm not very comfortable with having to use fileDelete and intermediate uncompiled files.


Is there any way to directly use export() towards a compiled dso?

Or better, is there a resource about saving and loading data files? I'm not having luck with google.

Link to comment
Share on other sites

Yeah, or you could stick all of those pieces of data on a ScriptObject and just write that out/read it back in. Or however you like.


Hell, in order to save the player's (and AI units') position, I just move the spawn points to the actors' positions/rotations and resave the level in a new save location (in My Documents//Saves/), and save the data in another file along side it. That way the whole package is saved in one spot without muddying up the original data.


Many ways to skin this cat, entirely up to you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...