Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Seventeen Uncles on Mon 29/12/2014 22:41:30

Title: Save/Load GUI tutorial outdated? (not working)
Post by: Seventeen Uncles on Mon 29/12/2014 22:41:30
Hello yet again :grin:

I've tried following this tutorial to create a save/load gui in my game, but its not working. Was wondering if its outdated or if somethings not right. I've followed it twice exactly.

http://www.adventuregamestudio.co.uk/wiki/Creating_Custom_Save_and_Load_Dialogs

error that comes up is
"ListBox.Items: Invalid index specified"

refering to this line:

Code (ags) Select

function txtSaveName_OnActivate(GUIControl *control)
{
  //put the selection in the save txt box
  txtSaveName.Text = lstSaveGames.Items[lstSaveGames.SelectedIndex];
}


as always any help would be greatly appreciated!

thanks

Title: Re: Save/Load GUI tutorial outdated? (not working)
Post by: Monsieur OUXX on Mon 29/12/2014 23:05:41
That's probably a small bug caused by the fact lstSaveGames.SelectedIndex is -1 (because no item is selected in the listbox) yet you clicked on "Save". Therefore, the script tries to access cell -1 of array  lstSaveGames.Items[], which is impossible.

From there you have two options :
- if you try to enhance your scripting skills, then go on trying to make your own custom save/load interface.
- if you want to save time and avoid extensive testing and corner-cases bugs, then use an out-of-the-box module : For example, this one (http://www.adventuregamestudio.co.uk/forums/index.php?topic=38928.msg512373#msg512373).
Title: Re: Save/Load GUI tutorial outdated? (not working)
Post by: ChamberOfFear on Mon 29/12/2014 23:12:57
The guide says that you're supposed to double-click the list box and add code there, but yours appear to be working on a text box. I would double-check that you're working on the correct GUI control, I followed the same example in my game and to me the function looks like this

Code (ags) Select

function lstSaveGames_OnSelectionChange(GUIControl *control)
{
  txtSaveName.Text = lstSaveGames.Items[lstSaveGames.SelectedIndex];
}
Title: Re: Save/Load GUI tutorial outdated? (not working)
Post by: Monsieur OUXX on Tue 30/12/2014 08:32:51
Quote from: ChamberOfFear on Mon 29/12/2014 23:12:57
but yours appear to be working on a text box.
Yes. His function is connected to the text box where the player types the game's name. I dion't think that's right.
Title: Re: Save/Load GUI tutorial outdated? (not working)
Post by: Seventeen Uncles on Wed 31/12/2014 00:18:31
i took the easy route and used the module, thanks v much for your help (both of you)