Simple Question Regarding: Shared Objects (Researched Forum in Advance!)
For my art-based rpg, I decided to try out Ed Mac's tut on Shared Objects and used the same info to create a feature in my game that allows you to name your character, save, and load the name. The name appears throught the storyline like alot of games do.
My question is, if I want to allow players to save more info and have it load later like the name character feat how would I do this? If I wanted to save for example: health, money, ect.
BTW, I have a hard time understanding the simplest thing. If you try to help me, please make your solution to my problem very clear. Keep in mind that I don't know alot of actionscript but, I'm willing to learn! Please bare with me.
Usually a .fla example or something helps alot but, I'm not asking you to code the whole thing yourself... I just need a little help or direction thats all. I researched the forum and didn't find an answer to my question so I am posting here.
Wow, thats awsome! Although I just wanted to be able to save more things like health, money, ect. This looks like it saves many files of a game which saves me quite alot of time asking how to do this later thanks.
As far as questions go, how do make it work with my game? Meaning once the file is saved and loaded, how do I get the loaded file to load the right info that was saved to appear in my game? Okay that sounded a bit confusing to me so let me restate my question. How do I make the loaded info so up in my game after pressing the load button? Yes, that is what I mean.
If I press load it should load the game file and the game should start where you last were with all your name & money the same.
hey kayol, i used the shared lib for my very old rocky game; all the variables (so game datas such as amount of rubies, health...etc) was saved in one single file...
i was using EdMack's code too, so you already have the prototypes... here the function is called SaveGame
Code:
// SAVE
// games language
SaveGame("NameOfYourSavedFile", "language", _root.language);
//money amount
SaveGame("NameOfYourSavedFile", "money", _root.moneyAmount);
Code:
// LOAD
// game language
_root.language = LoadGame("NameOfYourSavedFile", "language");
// money amount
_root.moneyAmount = LoadGame("NameOfYourSavedFile", "money");
"NameOfYourSavedFile" is here the name of the .sol file... you can create for example 3 accounts with differents games loaded when your RPG begins for example (i did it with rocky, if you want to test it, click the link in my signature, play "rocky raccoon" and save by talking to your plush ^^
the edit menu in my example is just to show that it works, just make it when you click menu or some point after no more vars will be changed, and set like item1 to health, item2 to money... then when you click start game set health to item1... if you are still confused ill make a further example
Okay, I tried your advise guys and I am still a little confused. Rocky rules and I would love to be able to make a save & load feature like that but without the language option. It seems to record health, money, and even location wow!
in fact you can save absolutely all that you want... the rocky example was the first time i used a shared lib (my first try in MX world ^^)
listen:
in the timeline, put:
Code:
MovieClip.prototype.SaveGame = function (c,n,v){
var so = SharedObject.getLocal(c);
so.data[n] = v;
so.flush();
};
MovieClip.prototype.LoadGame = function (c,n){
var so = SharedObject.getLocal(c);
return so.data[n];
};
now imagine you are saving your game (here the language) by pushing SPACE. put it under keyDown event:
Code:
if (Key.isDown(Key.SPACE)){
// game language
SaveGame("NameOfYourSavedFile", "language", _root.language);
}
1) "SaveGame" is the name of the function you have in the prototypes above
2) "NameOfYourSavedFile" is the name of the .sol file, that contains your saved data: choose freely the name you want
3) "language" is the name (choose freely the name you want) you give to store the data
4) _root.language is what you are saving. here you are saving the variable _root.language. imagine _root.language ="french". so "french" will be saved as "language"
NOW, load it back
Code:
if (Key.isDown(what you want here)){
// game language
_root.language = LoadGame("NameOfYourSavedFile", "language");
}
1) _root.language is the name of the variable you will use in the game to check the language
2) "LoadGame" is the name of the function you have in the prototypes above
3) "NameOfYourSavedFile" same as before...
4) "language" is the name of the data you stored in the SaveGame function (="french")
> so now, _root.language = "french"
in my rocky game, i used 3 different files to save datas (so you had the ability to play 3 different saved games): i did that way: "NameOfYourSavedFile" was named "file01", or "file02", or "file03", depending on another variable...