• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Best way to save a game?

H

Harper

Guest
I apologize, I see there are other sources on this but my school wifi has blocked nearly everything. Basically, i'm trying to get an understanding of all the methods of saving, but it's so diverse i'm having trouble locking down on everything.

Right now I'm using ini saving, but I want to add an inventory to my game and I've heard that ds maps/lists are better for that. I've also been recommended to use buffers/binary and text files, but I'm really having trouble grasping down on the differences.

Thanks!!!
 

Binsk

Member
Maps, Buffers, Lists, they are all just structures for storing data in memory in different ways. People might be suggesting them because these structures have built-in functions that will save and load all their data to a file automatically. I'm not going to go into great detail about each, as you can find descriptions in the manual, but the rough idea is this:
1) Maps: They act like a grocery list you can add things to. For each entry you have a "key" (the item on the grocery list) and a "value" (the number of the item). Maps can store any number of entries.
2) Buffers: These are low-level data storage that allows you store data at the byte-level. You can specify to the level of ints, floats, shorts, etc. If these terms are not familiar to you, don't use buffers.
3) Lists: These are literally just a series of values. It's like the grocery list without the "value" portion. So you could specify to store "Eggs, Bacon, Cheese" but not how much of each.

Each type has something they are good at. For example, finding a value in a map is super quick but trying to read each value in a predictable order is no good. Lists, accessing a value if you know where it is or storing things in a specific order is fantastic but finding a specific entry is not great as you have to traverse the whole list. Buffers are great for storing and mutating data at the byte level and are fast to access but you have to keep track of locations and meta-data yourself.

As for actually using the file_text_* operations, these let you actually write data into a file line-by-line. You have to do all the formatting yourself but it gives you the most flexibility. As said, with maps and things above, they have built-in file saving functions so you could use those or alternatively manually write everything with file_text_* functions.
 
Top