Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ShrillMegaTonsec on Thu 18/04/2024 18:41:17

Title: Need help with custom load button (SOLVED)
Post by: ShrillMegaTonsec on Thu 18/04/2024 18:41:17
hello, im working on my own project using the sierra template and while creating the main enu i've run into a problem
I can't get the second "load" button i made to reload the saves

function btnLoad2_OnClick(GUIControl *control, MouseButton button)
{
  RestoreGameSlot(0);
}

how can I get it to load the first slot? I tried putting int 1 but that didn't anything
Title: Re: Need help with custom load button
Post by: Crimson Wizard on Thu 18/04/2024 19:30:24
First of all, check if this function is run at all. The easiest way to do so is to add "Display("i am here!");" command there.

If it is not run, double check that you have connected this function to the button's event, on its events page.

Finally, does the save in question actually exist?
Title: Re: Need help with custom load button
Post by: ShrillMegaTonsec on Thu 18/04/2024 19:59:26
Quote from: Crimson Wizard on Thu 18/04/2024 19:30:24First of all, check if this function is run at all. The easiest way to do so is to add "Display("i am here!");" command there.

If it is not run, double check that you have connected this function to the button's event, on its events page.

Finally, does the save in question actually exist?

hey

so i tried to check if the function is working by doing what you said and nothing happened unfortunately

i tried to set the event from the gui's command too and nothing happened

and i did save in game using the default settings

function btnLoad2_OnClick(GUIControl *control, MouseButton button)
{
  Display("im here");
  {
  RestoreGameSlot(0);
}
}


function gTest2_OnClick(GUI *theGui, MouseButton button)
{
  Display("im here");
  if (lstRestoreGamesList.SelectedIndex >=0)
  {
   
    RestoreGameSlot(0);
  }
 
}
Title: Re: Need help with custom load button
Post by: Crimson Wizard on Thu 18/04/2024 20:32:32
Do you actually connect these functions to gui events, or just copy/paste them into the script?

The gui functions should be connected to events, similar to how shown on this screenshot:
https://adventuregamestudio.github.io/ags-manual/images/acintro3_03.png
Title: Re: Need help with custom load button
Post by: ShrillMegaTonsec on Thu 18/04/2024 20:38:01
Quote from: Crimson Wizard on Thu 18/04/2024 20:32:32Do you actually connect these functions to gui events, or just copy/paste them into the script?

The gui functions should be connected to events, similar to how shown on this screenshot:
https://adventuregamestudio.github.io/ags-manual/images/acintro3_03.png

I didn't copy and paste anything I actually went to the button and gui's event and picked onClick on both

Now what?
Title: Re: Need help with custom load button
Post by: ShrillMegaTonsec on Thu 18/04/2024 21:03:38
Quote from: Crimson Wizard on Thu 18/04/2024 20:32:32Do you actually connect these functions to gui events, or just copy/paste them into the script?

The gui functions should be connected to events, similar to how shown on this screenshot:
https://adventuregamestudio.github.io/ags-manual/images/acintro3_03.png

nvm! i fixed it by basically re-routing the save slot from the save button found in gSaveGame

i did this for the save button script:
{
Display("Game Saved!");
SaveGameSlot(1, "SaveGame1");
}

and for the load function i did the following:
{
if(Game.GetSaveSlotDescription(1) !=Null)}
Display("Save file loaded");
RestoreGameSlot(1);
{

thanks for reaching out though i appreciate that