Mxthe
Registered 02/06/2009
Points 532
|
Hey folks, for this second thread on Making Off Wargame, I'm going to explain how I made the save game system and the Data storage !
Now before all, I'm going to tell you which extension I used, because a lot of people wonder what to use...
The extension I used was the "Data Store 2 object" and not the Save Game object or Ini object...
I used this one because it seemed to be the easiest to me, and it works like a charm !
Basically, every data in every game, is either a string, or a value...(Do you know any data that's not a number or a letter?)
So what I did? Not that complicated, MMF2 has infinite general values, you might think there are only from A to Z which means 26 (Hey guys ! I know how many letters there are in the alphabet !)
But that's not it ! Right next to the name of the value, there is an expression button, press it, and you can enter a number for the value ! Now you have to understand, that the values from A to Z are only named as letters in the application, because in game, they are actually named as numbers !
Don't believe me? Run the game with the debugger, and watch the ingame values...You're going to see numbers...
So basically, if you use the A to Z values, all your values from 0 to 25, are going to be used, so if you want more, start by the value 26 ! Then you're fine.
So all I did, was that each time the player leaves the application, all the general values are stored in the Data Store 2 Object, as a corresponding value number, and then, the Data Store 2 Object saves the data, in any directory you want (Use the $AppPath code to trace where ever the application is, you can find out about the codes by clicking in the system options while writting an expression)
So that's it for the save data thing...But then, to load it? Its just the reverse operation, at the begining of the frame, or any other event you want, you simply set all the general values to the data store to object's corresponding values, but before that remember to load the right file for the Data Store 2 Object.
So that's it to save and load ! But what about the profiles !!! Oh boy, that took me some time to figure it out !
You might not believe me, but I have not read ANY tutorial during the making of this game...Yeah that's right, I actually figured all out alone...
I'm going to explain the basics, but not everything in detail hehe, but I'm sure you're going to understand...
Basically, I used a list object to select the profiles, now the List object, I discovered to be quite...How to say? Problematic...
Because, first, it conflicts with the Control X object, don't ask me why, when the list object is shown, or hidden at the begining of the frame, it disables the Control X Object, that's weird, I don't know if that was only in my game, but it happened ! The solution I found, was that, at the begining of the scene, the List object's position is set outside the frame, then the list object is shown, and each time the player goes in the controls options, the list object hides...That's the solution I found to fix this MMF2 glitch...I don't know if you guys have that problem, but it happened to me so, theres the solution !
Now about the profiling, well it's not really complicated once you get it !
You need a string object, for the current player name, a text input object, to enter the player name, and the data store 2 object to save the data...
Basically with the input object, you set the player name, then the current player name's string is set to the string of the input object, and a line is added to the list, then each time the application ends, the data store 2 objects saves the file under the name :
Apppath$+"\Saves\"+"Wargame_Savedata"+"_"+string$( "Player One Name" )
Let me explain that code, the Appath is the path of the application, the \Saves\ is the name of the folder you want your save game to be stored in, the Wargame_Savedata is the main name for the data, and the +"_" is to separate the main name and the profile name, and the +string$( "Player One Name" ) is the string from the current player string...
So lets review all that, the player enters the name of the profile, it sets the current player string to the string he entered, it adds a line to the list, and the data store to object saves all the values under the filename of the right profile, then we need to save the various profiles of the list, thankfully, the list object has an action for that ! You just have to set it to save the List file wherever you want, and to load it whenever you want, no need to save the list file under any profile name, because this is the file where all the profile's name will be stored, so you only need one instance of it...
Now to load the profile ? Just set that when you click on a Load button, the Data Store 2 object will load the file :
Apppath$+"\Saves\"+"Wargame_Savedata_"+List Select$( "List" )
Basically, it will load the file Wargame_savedata_ + the string of the current selected line! Understand how it works? It's not that complicated, and it works fine !
Now you can go even further than that, by making that player's cant create 2 profiles with the same name, using the list's option "Find String", basically how this works :
When you hit the Ok button to create a profile, the list will search the string from the input object inside the list, and if it finds it, then the profile doesn't create, and you put a notify message for the player.
Now what about minimum profile length? Create a counter or use an alterable value that always counts the lengh of the string in the input object, and when the player hits the okay key, and that the value of the counter or the alterable value is higher than 2 or 3, or the minimum number of letters you want, it creates the profile, if it is lower or equal, it doesn't and you put a notifying message for the player.
I think this covers the basics about the profile management and data storage...
Any questions or suggestions, this thread is made for it !
(\___/) This is bunny.
( ='.'= )Copy him into your signature to
(")__(")help him domintate the world
|