Go to content

Main menu:

The Basics of Saving Data in Multimedia Fusion 2 and Clickteam Fusion

Last Updated: May 8th, 2015
At some point in all but the smallest applications and games, you will want to save data. MMFusion offers a wide variety of options to save data. This tutorial will explain two fundamental ways of saving within MMFusion (the Array and INI objects), discuss the proper usages of each, and evaluate the advantages and disadvantages of each.

Quick Links:
Saving Methods

Within MMFusion, the programmer is given a wide choice of ways to save including but not limited to the Array Object, Dynamic Array Object, Binary Tree Object, INI Object and INI++ objects. Out of the listed objects, two are of the most fundamental with regards to saving; the Array object and the INI object.



Array Object Basics

One definition of an array is as follows:

"An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier"


For those new to arrays or programming, an array can simply be thought of as a table or list where all the data elements are the same type (all integers, booleans, strings, etc...). The tables below represent string arrays of different sizes. Essentially anything that makes sense to add as a column or row in a table could be added as another dimension in an array. This concept applies to any kind of array.

1 x 3 Array Example

Name

Mario

Donky Kong

The Doctor

Link

2 x 3 Array Example

Name

Age (in years)

Mario

28

Donkey Kong

34

The Doctor

1200

Link

19

3 x 3 Array Example

Name

Age (in years)

Favorite Meal

Mario

28

Mushrooms

Donkey Kong

34

Bananas

The Doctor

1200

Yogurt

Link

19

Potions & Soup

Saving Methods

The Array Object in MMFusion supports a maximum of 3 dimensions; X, Y, and Z dimensions. The dimensional length of each array can be any positive integer. Arrays that use all 3 dimensions can quickly use a large amount of memory. Exceeding a 2GB limit will cause a warning message to appear so try to limit the dimensional lengths.

MMFusion arrays are either number arrays or text arrays. If you array may contain text and numbers, set the array to be a "text array" so you can use the Val() function to convert numbers in string/text format to numbers in numeric format.

The norm for programmers is to use a 0-based index; meaning that numbers start at 0 instead of 1. Most extensions that use indices in MMFusion are 0 based indices so it is recommended against checking the "Based 1 index" property for consistency and uniformity.

Finally, arrays in MMFusion can be global. A global array means that the data of the object is retained throughout frames. If this property is enabled, all Array Objects that share the same name as the global array will be global. As such, you can have multiple global arrays across the application.

Array Object Properties
Array Object Properties
Image showing all the properties of Multimedia Fusion and Clickteam Arrays
Arrays in MMFusion - Event Editor

Using the Array Object is fairly straightforward. You write string or numerical data to a specified index. Additionally, you can also load or save an array via a filename expression or a file selector.

Special Notes:

  • The files the Array Object creates are only readable by MMFusion. The filename generated by the object can any type of file extension to it.

  • There is a way increase the dimensional size of an array during runtime. Simply write data (it can be a blank string or 0) to an address outside of current dimension of the array. For example, if you saved "John" to (99,99) in a 0-based 3 x 3 array, the 3 x 3 array would increase to 100 x 100 array.

  • The only way to decrease the dimensional size of an array is to leave the frame and come back or restart the frame. This will cause the array to revert to its original size. This will only work if the array is not global. Global arrays cannot be reduced in sized.

An Example Array
   
 
X Indices (data of the same type lie on the same X-Index)
0
(represents Character Name)
1
(represents Character Age)
2
(represents Favorite Meal)
3
(represents symoblic clothing)
Y-Indices
(related data lie on the same Y-index)
0
Mario28MushroomsRed hat
1Donkey Kong
34BananasDK Tie
2The Doctor1200YougurtSonic Screwdriver
3Link19Potions & SoupGreen tunic
How would you access the various data item in this array? You would access "Mario" by accessing (0,0). All of Mario's data lie on (x,0) where x is any valid index. Similarly, all of the character names lie on (0,x). Learning how to access arrays and how to group related data makes arrays extremely strong.
Arrays in MMFusion - Advantages
  • Saves and loads data quickly; faster than the INI Object
  • Difficult to externally manipulate array files
  • Extremely easy to find each data element in an array
  • Array can be global across frames
  • Overall smaller size than the INI object (assuming both held the same set of data)
  • Array data exist in internal memory rather than just a local file
  • All array operations are executed on data in memory
  • Easy to iterate through the array
Arrays in MMFusion - Disadvantages
  • No way to decrease size of array during runtime through actions

  • Concept of arrays difficult to grasp for newcomers and those unfamiliar

  • Large arrays can take up increasingly huge amounts memory

  • Indices are only addressable by numbers (not so much of a disadvantage, but takes time to get used to)

INI Object Basics

Below is one among many definitions for an INI,

"The INI file format is an informal standard for configuration files for some platforms or software. INI files are simple text files with a basic structure composed of 'sections' and 'properties' "


Simply put, INI files typically hold configurations/settings. If you have a Windows computer, you see this for yourself. Open Notepad, click "Save as" then type in a name with the extension '.ini' such as "Settings.ini". Then view this file in the Windows Explorer (Windows key + E) and you will see in the description that the Window classifies it as configurations. Keep in mind that adding the '.ini' extension does not add any kind of extra or special code to the text file; the INI file is still a plain empty text file.

Example INI File
Example of an INI File
The Sections of an INI

As stated before, the norm is for the data within .ini files be used to "personalize" a piece of software to its user(s). There are four sections in a plain INI file.

  1. Located between square brackets [ ] is the group name. Each line under the group is part of the group. Example: [MyGroupName]
  2. The next section in INI files is the delimiter field. A delimiters is just a character that is used to differentiate between a sequence of characters. For example, the English language uses the space character as a delimiter, meaning we can know where a word starts and ends by looking for spaces. In MMFusion, the default delimiter is the '=' character (equal sign). The delimiter in INIs separates the name and value sections. Example: MyItemName = MyItemValue
  3. The name section always appears on the left side of the delimiter. Typically a string, this section is the name data field type. Example: MyItemName = MyItemValue
  4. The value section always appears on the right side of the delimiter. The value section is a string, but can represent other data types such as integers, booleans, floating-point numbers, etc... It represents the value of its name field. Example: MyItemName = MyItemValue
INI Properties

The only property the INI Object contains asks for the name of the initial INI file. Any filepath is a valid value for this field. If the "Create INI file in Application Data folder" is checked, then a folder with the same name as the application will be created in the application data folder and the INI Object's initial file is saved and loaded from there.

INIs in MMFusion - Event Editor

Similar to the Array Object, using the INI Object is fairly straight forward. You can choose the set the current group and current item which will write the next set of data to the chosen group and/or item. The Load/Save Object Position saves the name of the chosen object and the selected X/Y Positions of the chosen object. No alterable values or alterable strings are saved with this action. These two actions can be useful in level editors, but it is recommended to use a custom-built saving routine. This is recommended because a custom-built saving routine will be much more flexible to suit your needs in applications.

INIs in MMFusion - Advantages
  • Human-friendly format

  • Personalized structure in groups (different groups can have different sizes)

  • INI files can be as big or as small as you need it to be

  • INI concept easy to grasp

INIs in MMFusion - Disadvantages
  • Easy to externally manipulate INI files
  • Saves and loads data slower than the Array Object; generally slower than other data storage methods
  • Extremely difficult to loop through all data elements in INI file
  • Impossible to find data elements in groups unless you know exactly where you should be looking (already know all the group names and item names)
  • No explicit expression to retrieve the group count
  • No explicit expression to retrieve the item count within a group
  • No expression to retrieve Nth group/item
  • Larger file size than the Array Object (assuming both hold the same set of data)
  • Default ~64kb file size limit on older Windows operating systems (pre-Vista)
  • No data is loaded into memory. All data is immediately saved to or loaded from the INI file



Summary

Arrays and INI files are two out of a vast number of options to save data in applications. Using both objects is fairly straightforward; you specify where you want to save the data and write said data to the file. The Array Object should be used over the INI Object in most cases. Such reasons why you would use the Array object over the INI object include if you need the data to be illegible to users, need a small file size, or have a table-like structure. The INI Object should be used over the Array Object if you wish the data to be editable by the users or have an inconsistent data structure. An example flow chart, below, shows compares the uses of both objects


Each object has its advantages and disadvantages, but it is up to you, the programmer, to make the best out of both!

When to use the Array Object vs. the INI Object
When to use the Array Object vs. the INI Object

Rate This Tutorial
Vote: 4.8/5
If you have read this tutorial, rate it from poor (1) to average (3) to great (5)!
Back to content | Back to main menu