Level 17 Lesson 01 [ ini File Writing/Reading ]

Introduction
One way to save information to the file system involves writing and reading from an initialization file (.ini file). Using .ini files is fast and easy. The information is organized inside of them into sections and each piece of data is given a ‘key’ name to help you find the data quickly. In the following four parts you will learn to use .ini files for some simple tasks like saving user preferences, and for some longer tasks like saving and loading room/level information.

Part A – INI File Basics
In this part you will learn how to create an .ini file, write numbers and text to key values, and read these values back into the game.

Watch the video: 17-01-A
Done File: 17-01-ABCD-Done.gmk

Part B – INI Files and Lists
In Part A you saved key/value pairs into an .ini file. In this part you will save the positions of many game pieces into an .ini using just one key and a ds_list. Saving lists into .ini files is one way to store lots of values into your .ini files without having to create hundreds of key values.

Watch the video: 17-01-B
Done File: 17-01-ABCD-Done.gmk


Part C – INI Files and Maps
Lists are useful for storing many values into one key in a file. Maps can be even more useful depending on the tasks. In this example a map is used to save some user preferences for easy writing and reading.

Watch the video: 17-01-C
Done File: 17-01-ABCD-Done.gmk


Part D – INI Files and Grids
Want to store an entire room or level into a file? This example will show you using a grid data structure to save and load the type and position of objects in a room. Very useful for saving and loading levels, but also very useful for any type of save that requires you save lots of organized data.

Watch the video: 17-01-D
Done File: 17-01-ABCD-Done.gmk