Many AGS developers like the way the default Save and Restore GUIs work. They just dislike the way they look. I know I do. That boring gray color... ugh. ;) And since many find it difficult to make Save and Load GUIs themselves they usually just leave the default GUIs in their games.
So here I present you Simple Save & Load GUIs. They pretty much work exactly the way the AGS default GUIs work. But now you have the chance to change their graphical outfit! I also have added a savegame deleting feature for both GUIs.
Download Simple Save & Load 1.0 here! (http://koti.mbnet.fi/pabsoft/ags/simplesaveload_1_0.zip)
Mirror (http://www.2dadventure.com/ags/simplesaveload_1_0.zip) (Thanks Neole!)
Just import all the GUIs and the module into the AGS editor and put the following codes where you want to open the GUIs. (ie. inside on_key_press):
SaveLoad.OpenSaveGUI();
SaveLoad.OpenRestoreGUI();
I think I've gotten rid of all the major bugs, but please report here if you find any. :)
Good!
But what about an All-together SAVE-RESTORE-DELETE game dialog??
One GUI to do it all!? WHOA!
It would be pretty easy, though, to copy some buttons and move some code to put everything on one GUI, if that's what you need.
One GUI to do it all, indeed. I reccommend anyone interested in THAT to check out Xmas Quest 2 - http://www.adventuregamestudio.co.uk/games.php?category=101&action=download&game=824.
One GUI to do it all, and absolutely lovely.
It's not difficult to make one GUI contain all of the Save and Load stuff. It's just that I wanted this to be exactly like the default AGS interface but modifyable. :)
I made a game called Shoot My Valentine. Well I used your module in it. Then someone who played the game send me this message:
Quote from: sthomannch on Tue 06/02/2007 16:52:51Unfortunately, I can't restore a game. Also, my single savegame appears several times with the same name in the file selection box. When I restore, the game simply crashes. I should have played through it...
I only did those things:
changed the background images.
added those lines at the key press.
I thought you should be aware of this. Check it out and let me know of the solution of this problem.
As you see from Dualnames' post (thanks for the report!), it's very buggy at the moment so I suggest you not to use it before I update it. I probably should recode the whole thing to remove (hopefully) all the bugs. At the moment the script is pretty confusing.
I promise I'll do it... someday... sooner or later. Probably later. ¬¬
Well I beta tested my game with your GUI many times loading saving. Well it seems that the guy who had a problem was an exception your GUI works just fine.
Hi I'm having a little bit of a problem when I try to use this module!
The problem is that when I try testing my game it says there is a script error
and I tried putting the functions on there too and that didn't work either.
Could you elaborate a bit? What kind of a script error? Could you maybe copy+paste the whole error message here. Have you imported all the GUIs and the module too? What exactly did you write in the script file and where? Are you using AGS 2.72? With the little information you've provided so far I can't really solve the problem.
This is the exact error message I got
Compile error
There was an error compiling your script.
problem was in:`Simple Save & Load'
Error (line 1): Variable `SaveLoad' is already defined
Do you want fix script now?(Your game has not been saved.
The version I'm using is 2.71 Not sure if I imported all GUIs and I wrote
SaveLoad.OpenRestoreGUI();
SaveLoad.OpenSaveGUI(); in the script. Oh and by the way sorry. It wasn't a script error it was a compile error. My bad!
I need you to be more specific. Where exactly did you write the script commands? Could you paste part of the script here so I can see where you put them. You're supposed to run the OpenRestoreGUI and OpenSaveGUI commands from some main function that controls an action in the game, for example from inside on_key_press.
Sorry I took so long my computer needed a new operating system so I couldn't access my game for a while but heres part of my script
function SaveLoad.OpenRestoreGUI();
function SaveLoad.OpenSaveGUI();
// Main script for module 'Save & Load'
int exMouse;
export exMouse;
int deletedSave;
export deletedSave;
function game_start() {
//Remove the following lines if you wish not to center all the GUIs.
gSave.Centre();
gRestore.Centre();
gDeleteconfirm.Centre();
////////////////////////////////////////////////////////////////////
}
function repeatedly_execute() {
if (lstRestoreList.ItemCount > lstRestoreList.RowCount) {
if (lstRestoreList.TopItem == 0) {
btnRestoreUp.Visible = false;
btnRestoreDown.Visible = true;
}
else if (lstRestoreList.TopItem == lstRestoreList.ItemCount-lstRestoreList.RowCount) {
btnRestoreDown.Visible = false;
btnRestoreUp.Visible = true;
Okay. That's not how you do it. Remove those two lines from the top of the script.
First of all, if you write "function" in the beginning of a line, it means you are declaring a function, which is not what you want to do. I suggest you read about functions and how they work in the manual and also try and learn the basics of how scripting works.
You also don't need to open the module or modify it in any way. What you do need to do is replace every SaveGameDialog-function you may have in your global script with "SaveLoad.OpenSaveGUI();". The same thing with RestoreGameDialog, except of course then you will have to write "SaveLoad.OpenRestoreGUI();".
So for example if your on_key_press looks like this:
function on_key_press(int keycode) {
// called when a key is pressed. keycode holds the key's ASCII code
if (keycode==363) SaveGameDialog(); // F5
if (keycode==365) RestoreGameDialog(); // F7
}
You will want to modify it like this:
function on_key_press(int keycode) {
// called when a key is pressed. keycode holds the key's ASCII code
if (keycode==363) SaveLoad.OpenSaveGUI(); // F5
if (keycode==365) SaveLoad.OpenRestoreGUI(); // F7
}
This will run the functions declared in the Simple Save&Load -module, instead of running the default functions of AGS.
I hope this is clear enough. If you have any further questions, don't hesitate to ask. :)
Thank you for the help now I have just one more thing to ask ags basicly gave me messages to delete a lot of script of which I already did and I have no problems with my game yet when I test it but did I do the right thing deleting the script it asked me to delete I mean was I soppose to delete what I deleted thanx again for all your help
I'm sorry but I seriously can't understand what you're asking. You're telling me AGS told you to delete some script. Which script? You can't expect me to read your mind.
I forget exactly what it told me to delete but a lot of it had to do with saves and loads but from what you wrote it sounds like I wasn't soppose to delete anything but in test mode the game still saves and loads fine but thats all I can tell you cause whats gone is gone but thanx for all the help if I need anything else I'll let you know
Can you tell me where the saves go? I am using this module, and BTW it is great, but I can't find the saves. Also, do you know the max number of saves this will allow?
For me they go in C:\Users\"username"\Documents\SavedGames
I think it was 99 saveslots. From what I remember when I used it.
And there they were. Thank you!
I can only restore back into the game, the last 20 saves. It I select save 21 or any save greater than the 20th save, I get this message.
Error: Error running function 'restoregame_Click'
Error: Array index out of bounds(index 21, bounds:0..19)
This is the area in the script the error is pointing to. Anyone see where the problem is?
function restoregame_Click(GUIControl *control, MouseButton button) {
aSound11.Play();
if(partidas.ItemCount!=0){
int index = partidas.SelectedIndex;
RestoreGameSlot(savegameindex[index]);
partidas.FillSaveGameList();
savegame.Enabled=true;
guardar.Enabled=true;
cerrar.Enabled=true;
SetGameOption(OPT_WHENGUIDISABLED, 2);
}else {
gSavemsg.Visible=true;
savemsglbl.TextColor = 65296;
savemsglbl.Text = ("There is no game to load");
Wait(80);
gSavemsg.Visible=false; }
I'm not sure, but it appears the error comes on line RestoreGameSlot.
Whether the savegameindex array is defined as:
int savegameindex[21];
And therefore it crashes on 21, or it's some old array i don't recall. So either replace the RestoreGameSlot with what i have below or increase the array size.
int savegameindex[50];
function restoregame_Click(GUIControl *control, MouseButton button)
{
aSound11.Play();
if(partidas.ItemCount!=0)
{
int index = partidas.SelectedIndex;
RestoreGameSlot(partidas.SaveGameSlots[[index]);
partidas.FillSaveGameList();
savegame.Enabled=true;
guardar.Enabled=true;
cerrar.Enabled=true;
SetGameOption(OPT_WHENGUIDISABLED, 2);
}
else
{
gSavemsg.Visible=true;
savemsglbl.TextColor = 65296;
savemsglbl.Text = ("There is no game to load");
Wait(80);
gSavemsg.Visible=false;
}
}
I don't see where a "savegameindex' is being defined or initialized. When I tried to add one, I got an error. Here is the code from the globabl script.
#sectionstart partidas_SelectionChanged // DO NOT EDIT OR REMOVE THIS LINE
function partidas_SelectionChanged(GUIControl *control) {
guardar.Text=partidas.Items[partidas.SelectedIndex];
}
#sectionend partidas_SelectionChanged // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart guardar_Activate // DO NOT EDIT OR REMOVE THIS LINE
function guardar_Activate(GUIControl *control) {
if(guardar.Text==""){
gSavemsg.Visible=true;
savemsglbl.TextColor = 65296;
savemsglbl.Text = ("Please enter a name before saving");
//Display("Please enter a name before saving");
return;
}
int p = 0;
while(p<=partidas.ItemCount){
if((partidas.ItemCount>p)&&(partidas.Items[p]==guardar.Text)){
//Display("The game will be overwritten");
gOverwrite.Visible=true;
cerrar.Enabled=false;
gSavemsg.Visible=false;
return;
}
p++;
}
UnPauseGame();
gSaverestore.Visible=false;
SaveGameSlot(partidas.ItemCount+1, guardar.Text);
partidas.FillSaveGameList();
guardar.Text="";
gSavemsg.Visible=true;
savemsglbl.TextColor = 65296;
savemsglbl.Text = ("Game Saved");
Wait(80);
gSavemsg.Visible=false;
//Display("Game saved");
mouse.UseDefaultGraphic();
return;
}
#sectionend guardar_Activate // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart savegame_Click // DO NOT EDIT OR REMOVE THIS LINE
function savegame_Click(GUIControl *control, MouseButton button) {
aSound11.Play();
if(guardar.Text==""){
gSavemsg.Visible=true;
savemsglbl.TextColor = 65296;
savemsglbl.Text = ("Please enter a name before saving");
//Display("Please enter a name before saving");
return;
}
int p = 0;
while(p<=partidas.ItemCount){
if((partidas.ItemCount>p)&&(partidas.Items[p]==guardar.Text)){
//Display("The game will be overwritten");
gOverwrite.Visible=true;
cerrar.Enabled=false;
return;
}
p++;
}
UnPauseGame();
gSaverestore.Visible=false;
SaveGameSlot(partidas.ItemCount+1, guardar.Text);
partidas.FillSaveGameList();
guardar.Text="";
gSavemsg.Visible=true;
savemsglbl.TextColor = 65296;
savemsglbl.Text = ("Game Saved");
Wait(80);
gSavemsg.Visible=false;
//Display("Game saved");
mouse.UseDefaultGraphic();
UnPauseAudio();
return;
}
#sectionend savegame_Click // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart restoregame_Click // DO NOT EDIT OR REMOVE THIS LINE
function restoregame_Click(GUIControl *control, MouseButton button) {
aSound11.Play();
if(partidas.ItemCount!=0){
int index = partidas.SelectedIndex;
RestoreGameSlot(savegameindex[index]);
partidas.FillSaveGameList();
savegame.Enabled=true;
guardar.Enabled=true;
cerrar.Enabled=true;
SetGameOption(OPT_WHENGUIDISABLED, 2);
}else {
gSavemsg.Visible=true;
savemsglbl.TextColor = 65296;
savemsglbl.Text = ("There is no game to load");
Wait(80);
gSavemsg.Visible=false; }
//Display("There is no game to load");
}
#sectionend restoregame_Click // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart borrar_Click // DO NOT EDIT OR REMOVE THIS LINE
function borrar_Click(GUIControl *control, MouseButton button) {
aSound11.Play();
if(partidas.ItemCount>=1){
int index = partidas.SelectedIndex;
DeleteSaveSlot(savegameindex[index]);
partidas.FillSaveGameList();
}
}
#sectionend borrar_Click // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart cerrar_Click // DO NOT EDIT OR REMOVE THIS LINE
function cerrar_Click(GUIControl *control, MouseButton button) {
aSound11.Play();
UnPauseGame();
gSaverestore.Visible=false;
guardar.Text="";
mouse.UseDefaultGraphic();
UnPauseAudio();
}
#sectionend cerrar_Click // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart FlechaPartidasUP_btn_Click // DO NOT EDIT OR REMOVE THIS LINE
function FlechaPartidasUP_btn_Click(GUIControl *control, MouseButton button) {
aSound11.Play();
partidas.ScrollUp();
}
#sectionend FlechaPartidasUP_btn_Click // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart FlechaPartidasDOWN_btn_Click // DO NOT EDIT OR REMOVE THIS LINE
function FlechaPartidasDOWN_btn_Click(GUIControl *control, MouseButton button) {
aSound11.Play();
partidas.ScrollDown();
}
#sectionend FlechaPartidasDOWN_btn_Click // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart overwriteSI_btn_Click // DO NOT EDIT OR REMOVE THIS LINE
function overwriteSI_btn_Click(GUIControl *control, MouseButton button) {
aSound11.Play();
int p = 0;
while(p<=partidas.ItemCount){
if((partidas.ItemCount>p)&&(partidas.Items[p]==guardar.Text)){
UnPauseGame();
gOverwrite.Visible=false;
gSaverestore.Visible=false;
cerrar.Enabled=true;
SaveGameSlot(savegameindex[p], guardar.Text);
partidas.FillSaveGameList();
guardar.Text="";
gSavemsg.Visible=true;
savemsglbl.TextColor = 65296;
savemsglbl.Text = ("Game Overwritten");
Wait(80);
gSavemsg.Visible=false;
//Display("Game overwritten");
UnPauseAudio();
return;
}
p++;
}
}
#sectionend overwriteSI_btn_Click // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart overwriteNO_btn_Click // DO NOT EDIT OR REMOVE THIS LINE
function overwriteNO_btn_Click(GUIControl *control, MouseButton button) {
aSound11.Play();
gOverwrite.Visible=false;
cerrar.Enabled=true;
}
#sectionend overwriteNO_btn_Click // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart gSavemsg_Click // DO NOT EDIT OR REMOVE THIS LINE
function gSavemsg_Click(GUIControl *control, MouseButton button) {
if (mouse.IsButtonDown(eMouseLeft)) {
gSavemsg.Visible=false; }
}
#sectionend gSavemsg_Click // DO NOT EDIT OR REMOVE THIS LINE
Replace savegameindex[] with partidas.SaveGameSlots[] then?
That's my guess, here.
Are you saying replace
RestoreGameSlot(savegameindex[index]);
with
RestoreGameSlot(partidas.SaveGameSlots[index]);