Right. So you've made this really long RPG, and want to find a way to save the player's progress through it. But how do you do it?

There are many ways to save values onto the hard drive: INIs, Arrays, and Data Store 2s are the most used. I'll go over each object here.

INI

The INI object comes with TGF and MMF. It's the most basic form of saving data to disk, and the most commonly used. When created, you should be asked for a filename. If you just type in the

filename, it creates an INI in C:/Windows. If you want it in your game directory, use the event Set Current File, and set it to appdrive$+appdir$+myini.ini or whatever you want it to be called.

A typical INI file looks like this:

[Details]
XPos = 323
YPos = 67
PlayerName = Bill
Score = 2301

[Items]
MagicGobletFound = 0
ExplodingCowFound = 1
CrystalsHeld = 7

[Story]
TalkedToSusan = 1
AcceptedFrog = 0

...and so on. This is an example of a well-organised INI file. You can include (I think) 64k of stuff in an INI file, which is quite a lot. As you can see, it can store strings and values (and

flags - 0 is off and 1 is on). The names in square brackets are the names of the groups, and you can change what group to look in by using Set Current Group. The things before the equals signs are

items, and you are told what they currently hold. If I wanted to find out the number of crystals currently held, I would do:

Set Group to Items
Set Item to CrystalsHeld
Set Crystals Counter (or whatever) to value of(Ini) (this can be found in Retrieve data from an object)

Which sets the Crystals Counter to the number of the item CrystalsHeld. Easy, see? If you wanted to change the number of CrystalsHeld, you can use Set Value to 8 or whatever you want.

Now, about Load and Save position of object. The INI can save the positions of one or more objects in the current group. For example, if you saved the position of Ball when it was at 54,67 then

Pos.Ball=54,67 would be loaded into the INI file. If you were to load the position of Ball, it would set Balls X position to 54 and Y position to 67.

For a probably much better explained tutorial, see Popcorn's INI tutorial on the Read Only section of the Clickteam Forums.

Arrays

The Array object comes with MMF. It is very much like INI, and it can store literally thousands of values and strings in a 3-dimensional array if you wanted it to. Suppose its X Y and Z proportions were all 100, you would be

able to tinker about with a million items. However, this would take up 3.81Mb with just empty items! A 10x10x10 array gives you 1000 items, and only takes up 3.81kb when empty.

An Array can be complicated to begin with. You can use it like an INI - by setting the current X, Y and Z positions, then writing or reading the value or string from or to it. However, the Array also has the easier option of writing values to X,Y,Z - for example, you could write the value 4 to 3,6,8 in one action. Reading from arrays can be done in this way too.

Data Store 2

Data Store 2 is available for both MMF and TGF, and it can be downloaded from the Cellosoft website. It can store 1000 values, 50 strings, and 1000 flags. This is very easy to use, with no current positions or anything - you can just change, add, subtract, multiply, divide and mod values, change strings, and can turn on, off and toggle any or all flags. Getting values is also easy. The only question you could have is how to get a flag's state - use the expression Get Flag State, and it returns 1 if it's on or 0 if it's off.


I know, I spent most of the time focusing on INI in this article. This is because the Array is very much like INI, and Data Store 2 doesn't require much documentation.

Look out for Part 2 - Data Protection!

Shen