Simon Donkers's Game Maker site siteSimon Donkers's Game Maker site
Version: GM 5+6 Views: 5612 Script, Game Maker 5 and 6 compatible
Filesize: 1189 byte Creative Commons License

Save and load script

1/52/53/54/55/5 (36 votes)

A script which let the user enter a filename to save or to load a game with a standard windows message screen. An editable message screen can be achieved by using the open example on the examples page


 Save and load script
//////////////// Save and load script ////////////////////
//
// Copyright Simon Donkers 27-1-2005
// www.simondonkers.com - gmmentor@simondonkers.com
//
// argument0 = 0 for saving, 1 for loading
// argument1 = file extension. For example .sav
// Do not add a '*' sign for the extension
// standard directory is the directory the game stands in
//
/////////////////////////////////////////////////////
var Savegame,Loadgame;
if argument0 = 0 then
  {
  SaveGame = get_save_filename('SaveGame(*' + argument1 + ')|*' + argument1 + '', '');
  if SaveGame != '' then 
    if string_copy(SaveGame, string_length(SaveGame) - 3, 4) != argument1 then 
      SaveGame = SaveGame + argument1;
      game_save(SaveGame);
  }
else
  {
  LoadGame = get_open_filename('Save games|*' + argument1 + '', '');
  if (LoadGame != '') then 
    if file_exists(LoadGame) then 
      game_load(LoadGame);
  }

Tip: Have a look at the tutorial How to execute a script

User comments

 N/A posted at 2005-09-05 19:14:23Quote
good job
 N/A posted at 2005-09-30 19:19:04Quote
Don't work with gamemaker 6.1!
 N/A posted at 2006-05-03 19:14:36Quote
Of course that yes!
 schalk bower posted at 2006-05-06 05:44:42Quote
can u plz post an gm6 example any1?
 schalk bower posted at 2006-05-06 09:38:30Quote
wow thanks man this is the best script eva :) . this is going to make my game so better u are the best gamemaker scripter ever!!!!!!!
 Stijn posted at 2006-06-07 17:56:18Quote
Damn it wouldn\'t work; Wrong number of arguments :s
 GameMakinRyan posted at 2006-07-27 18:13:13Quote
No guys, if you want it to work, yuo have to set it up like this. Lets say you're running this script from a piece of code, it would look like this

save_load(0,'.sav');

*The save_load can be subsituted with the name of your script.
 samushi posted at 2006-10-30 10:58:21Quote
could u help me, cause I tried it and it didn't work! I put an action "execute a script", selected the saving one, and pressed ok. what aruments should i put there? what does mean "argument0 = 0 for saving, 1 for loading"?
 Simon Donkers posted at 2006-10-30 15:03:52Quote
Hello samushi.

To save a game with .sav extension you can use (if the script is named save_load)
save_load(0,'.sav');
To load the game you use:
save_load(1,'.sav');

See the tutorial 'How to execute a script' for more information. Enjoy.
 samushi posted at 2006-11-02 10:51:02Quote
WOW! thankz, man! this script has done so much! now my game is cooler and i understand GML better!
 Rob posted at 2006-12-13 19:16:03Quote
it doesn't work
 Donkey posted at 2007-01-02 13:59:04Quote
In wich event i have to put this?
I did release enter. but nothing happend... can you make a example please?
thank you.:)
 Thanks a bunch!!!!!!!!!!!!!!!!!!!! posted at 2007-03-29 03:08:40Quote
This is AWESOME!!!!!!!!!!!!!!!!!!!

THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 It works posted at 2007-05-12 18:41:42Quote
Like the name says man!
 Dalortins posted at 2007-07-07 20:32:47Quote
I used your script and made it as an action using Library Maker. But the script works for me and i like it.
 Trident posted at 2007-08-08 04:09:20Quote
AWESOME!!!!!!!!!!!!!!!!!!!!!!!!
 jared posted at 2007-09-21 18:23:39Quote
I just need some simple scripts for an RPG game that im doing for school can anyone help me???
 Dazzque posted at 2008-03-04 16:47:18Quote
Hey! I am the programmer of Doom Nightmare-Games and i just want to ask anyone about scripts. Ex. I want to make a WWW-button to my website in the game but it just wont work! I tried this:
{
action_website(my_home_page);
}
It just wont work! Can anyone guide me to a website for script-programming-amatours! Please!
 anon posted at 2008-03-22 04:26:37Quote
I keep getting an error:

In script script_:
Error in code at line 15:
SaveGame = get_save_filename('SaveGame(*' + argument1 + ')|*' + argument1 + '', '');

at position 48: Wrong type of arguments to +.

How can I resolve this?
 stefan posted at 2008-03-22 16:37:49Quote
i keep getting an error: to

the same as above, this messes.

Error in code at line 15:
SaveGame = get_save_filename('SaveGame(*' + argument1 + ')|*' + argument1 + '', '');

at position 48: Wrong type of arguments to +.

the script won't work at all. can you please a script that work.

Stefan.
 tyga101 posted at 2008-03-30 07:39:33Quote
Can you please help me make a platform game where the players sprite moves. The way I make it, when you have to move, it creates it again, right next to the privious one, thus, restarting the sprite and going to frame 0.HELP ME if you don't me.
 Viski posted at 2008-03-31 15:43:11Quote
Works fine for me. Thanks a lot! =)
 NN KH Maker posted at 2008-05-21 19:54:29Quote
yo :d nice script but dont know how to use it
 Mr.Noname posted at 2008-05-26 15:19:06Quote
tyga101,
i've seen many people have this problem and make a script called'image_single2'
in the script put:
image_index=argument0
image_speed=argument1
and lets say you want frame2 and speeds of 3
then have in code:
image_single2(2,3)
 zergber posted at 2008-08-07 07:40:29Quote
I don't know much about GML but it would be a good idea to put
if SaveGame != ''
before
game_save(SaveGame);
because if you push cancel it'll create an error.

Thanks for script :D

Reply

Name:
Site: