Save/Load GUI tutorial outdated? (not working)

Started by Seventeen Uncles, Mon 29/12/2014 22:41:30

Previous topic - Next topic

Seventeen Uncles

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

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


Monsieur OUXX

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.
 

ChamberOfFear

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

function lstSaveGames_OnSelectionChange(GUIControl *control)
{
  txtSaveName.Text = lstSaveGames.Items[lstSaveGames.SelectedIndex];
}

Monsieur OUXX

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.
 

Seventeen Uncles

#4
i took the easy route and used the module, thanks v much for your help (both of you)

SMF spam blocked by CleanTalk