problem with save/restore gui

Started by andrea, Thu 26/08/2004 12:07:27

Previous topic - Next topic

andrea

Hello,
I wanted a costumized save/restore gui and found the following script. it seems to be right, but won't work in my game: whenever I press the SAVE button in the game, I get the error:
"Error:ListBoxGetItemText: invalid item specified"
can anybody help me?

if (interface == SAVE) {         // if save interface
Ã,  Ã, if (button == 4) {
Ã,  Ã,  Ã,  ListBoxGetItemText(SAVE,1,ListBoxGetSelected(SAVE,1),text);
Ã,  Ã,  Ã,  SetTextBoxText(SAVE,2,text);
Ã,  Ã,  Ã,  index = 21;
Ã,  Ã,  }
Ã,  Ã,  if (button == 2 || button == 4) {
Ã,  Ã,  Ã,  Ã, GetTextBoxText(SAVE,2,text);       // Get the typed text
Ã,  Ã,  Ã,  Ã, if (StrCaseComp(text, "") != 0) {    // If text not empty
Ã,  Ã,  Ã,  Ã,  Ã,  InterfaceOff(SAVE);         // Close interface
Ã,  Ã,  Ã,  Ã,  Ã,  SetDefaultCursor();
Ã,  Ã,  Ã,  Ã,  Ã,  if (index < 20)   {         // if less than 20
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, index = ListBoxGetNumItems(SAVE,1);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SaveGameSlot(index+2,text);       // Save game (text as description)
Ã,  Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  Ã,  else {               // if saved games are 20
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, index = ListBoxGetSelected(SAVE,1);   // Get the selected save game
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SaveGameSlot(savegameindex[index],text);Ã,  // Overwrite the selected game
Ã,  Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã, }
Ã,  Ã,  }
Ã,  Ã,  if (button == 0) {
Ã,  Ã,  Ã,  Ã, InterfaceOff(SAVE);         // if cancel is pressed close interface
Ã,  Ã,  Ã,  Ã, SetDefaultCursor();
Ã,  Ã,  }
}

if (interface == LOAD) {
Ã,  Ã, if (button == 0) {             // if cancel is pressed
Ã,  Ã,  Ã,  InterfaceOff(LOAD);      Ã,  Ã,  Ã,  Ã,  // Close interface
Ã,  Ã,  Ã,  SetDefaultCursor();
Ã,  Ã, }
Ã,  Ã, else if (button == 3) {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã, index = ListBoxGetSelected(LOAD,1);   // else get the selected game
Ã,  Ã,  Ã,  Ã,  Ã,  Ã, RestoreGameSlot(savegameindex[index]);    // restore the game
Ã,  Ã, }
}

SilverWizard_OTF

ListBoxGetItemText(SAVE,1,ListBoxGetSelected(SAVE,1),text);

Maybe you shouldn't type the name of the interface SAVE, but its number. I mean, if SAVE's interface number is 2 then it should be:

ListBoxGetItemText(2,1,ListBoxGetSelected(2,1),text);

Also, maybe you shouldn't set "ListBoxGetSelected(2,1)". Maybe you should do :     int Box_Get = ListboxGetSelected(2,1);
and then:      ListBoxGetItemText(2,1,Box_Get),text);

It might work, i am not absolutely sure (something that rarely happens to a Wizard, by the way...).
"All we have to decide is what to do, with the time that is given to us"

andrea

thanks, but now there is an error in my script saying:

"Error(line172): undefined symbol 'ListBoxGetSelected'

maybe i did it wrong.
where do i have to put the

"int Box_Get = ListboxGetSelected(2,1);" ?!

I'm not really into scripting, sorry

SilverWizard_OTF

Well, do not do that (int box_get =....).

Do what you have done before, but like that:

ListBoxGetItemText(2,1,ListBoxGetSelected(2,1),text);
// where "2" is the number of your interface

It was wrong the: int box_get, do not do that.

Well, does it work now?

(Sorry for the confusion, but even a Wizard makes mistakes sometimes...!)
"All we have to decide is what to do, with the time that is given to us"

andrea

I found the mistake myself. it had something to do with some functions that I forgot to load when loading the save/restore gui (does that make sense? I don't mind. it works).

Thanks for your help anyway!

SMF spam blocked by CleanTalk