Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: .. on Fri 27/08/2004 22:00:53

Title: Saving
Post by: .. on Fri 27/08/2004 22:00:53
Hi

Is there a way to have like a save button that when you click automatically saves the game under a pre determined name for that section of the game?

For example if the player was in a church and they clicked save it would display a message like 'Game Saved' and when they next go to load it would be under - Church *ins Date Here*

??
Title: Re: Saving
Post by: Edwin Xie on Fri 27/08/2004 22:08:42
Uh, maybe maing a save GUI and then use GetRoomNumber and GetDate or something similar to that? And then....well look for the source code of the default save dialog.
Title: Re: Saving
Post by: Jay on Fri 27/08/2004 22:28:13
Yeah, basically what Edwinxie said.
You'd use something like,
if (character[EGO].room==whatever) SaveGameSlot (30, "Church");

Inserting the date would be a bit more complicated, but not too hard. You would use the GetTime() function.
Title: Re: Saving
Post by: SilverWizard_OTF on Sat 28/08/2004 13:41:40
You can create a variable, whose value will be changed according the room that the player will be in.
     Global script:
int Save_value;

At the end of global script you should type: export save_value, and at script header, import save_value. So to be able the room script to read and edit this value.
At the interaction editor--> before fade in, of each room, you should change its value,  (  Run script:  save_value= //room number) according to the room number, so to be able to keep track of where is the player.

Then, when character clicks SAVE button, run a script like that:
        if(save_value==4) SaveGameSlot(1,"Church", GetTime);
e.g.  if(save_value==5) SaveGameSlot(1,"Graveyard",GetTime);
Where 4 it is the Church's room number.
Where 5 is Graveyard's room number.

I am not sure about if it is right to add a GetTime command where i added it. Try first without it  ( SaveGameSlot(1,"Church");), then try to add the GetTime command where i put it.

I hope i helped a bit.
Title: Re: Saving
Post by: Ashen on Sat 28/08/2004 16:10:39
A similar but slightly different approach would be to use the 'Room Properties' function in the editor, and create a NAME property in each room, which would save you from having to have a different if (save_value == x) ... for each room. Then something like:

string savename;
string savedate;
GetRoomPropertyText("NAME", savename); // passes the rooms name, set in the editor, to the savename string
StrFormat (savedate, " %d/%d", GetTime (4), GetTime(5)); // passes the date to the savedate string
StrCat (savename, savedate); // combines the two
SaveGameSlot (3, savename); // saves to slot 3


Or whatever works for your save GUI. This'll save to slot 3 with a name like 'Church 28/8'
Title: Re: Saving
Post by: Phemar on Sat 28/08/2004 18:50:02

I think Ashen's got it.