Spike Posted December 20, 2006 Report Share Posted December 20, 2006 Hey. I've been using GM for a long time now, but I've never had a save feature in any of my games, so I asm kinda vague on this. I heard that you can use .ini files to save certain information in a .txt-like file (So that in the load game screen, when you are choosing a slot to load, it will show certain things that are in that file. Such as the character you were, the emeralds you had, lives, etc.) but the manual (As on most subjects) doesn't explain how to use them worth crap. Also, how would I go about saving and loading without those gross looking windows file selects (As in choosing a slot in-game, and auto-saving to that slot always)? Any help is appreciated. Link to comment Share on other sites More sharing options...
UltimateSonic Posted December 20, 2006 Report Share Posted December 20, 2006 Use arrays: http://sfghq.emulationzone.org/view_info.php?sec=4&id=136 Link to comment Share on other sites More sharing options...
USC Posted December 20, 2006 Report Share Posted December 20, 2006 If only that wasn't MMF-Only... Anyways Spike, basically you use .INI files to save information into a text file (just save something in Notepad, then go to it and change the extension to .INI, and you've got one). Then, when your program's loading or whatnot, you call the .ini file and store values of it into a variable. I'm not too familar with GM's syntax however, so I can't give you a good example. I'd suggest searching the GM forums for .ini files, and they should include what you'd have to type. EDIT: Try this... http://forums.gamemaker.nl/lofiversion/index.php/t86175.html Link to comment Share on other sites More sharing options...
UltimateSonic Posted December 21, 2006 Report Share Posted December 21, 2006 Oh oops XD I completely missed the fact that he said GM my mistake! =P Link to comment Share on other sites More sharing options...
Kain Posted December 21, 2006 Report Share Posted December 21, 2006 It all depends on what kind of data you want to save and load. Personally, I like GM's binary file functions because you have complete control over each bit, but it's definately the hardest to use since it's so... general. Anyway, I've never used .ini files since, in addition to them being designed to be edited by any random person, they're also a waste of space, but saving and loading is simple with these things. Here's a quick example: Save: ini_open("save1.ini"); ini_write_real("Current Man","level",global.current_level); ini_write_real("Current Man","lives",lives); ini_write_real("Current Man","emeralds",global.emeralds); ini_close(); Load: ini_open("save1.ini"); global.current_level = ini_read_real("Current Man","level"); lives = ini_read_real("Current Man","lives"); global.emeralds = ini_read_real("Current Man","emeralds"); ini_close(); The ini file will look something like: [Current Man] level = 9 lives = 4 emeralds = 6 The best part about ini files is it doesn't matter what order you read or write them, as long as you get the sections and keys right. With the other file types (text and binary), you generally write all your data in a certain order then read them in the exact same order, but formatting can be a pain. Link to comment Share on other sites More sharing options...
Spike Posted December 21, 2006 Author Report Share Posted December 21, 2006 Wow, thats exactly what I wanted! Thank you! Does anyone know about the invisible auto-saving part? Link to comment Share on other sites More sharing options...
Kain Posted December 21, 2006 Report Share Posted December 21, 2006 If you keep a global variable to store which slot or file you're saving on to, you just have to create a save script (with slot or file name as a variable argument) and put calls to them at convenient places. Like at the start or end of significant rooms. Since your save files aren't going to be 10MB long and since they're on the hardrive, the user will hardly notice any slowdown, so feel free to put them pretty much everywhere (except in the step event, obviously). Link to comment Share on other sites More sharing options...
Recommended Posts