Custom Save/Restore Game help!! (Solved! Mods, lock please)

Started by BerserkerTails, Mon 14/06/2004 06:47:46

Previous topic - Next topic

BerserkerTails

Okay, I've been working at this for two hours to no avail... I was hoping someone could help me. I've been trying to make a custom Save/Load GUI for my game, and I'm completely stuck. I'm *TRYING* to follow the tutorial at GAC (http://atticwindow.adventuredevelopers.com/tutorials.php?id=1), and here's my Global Script:

  if (interface == 4) {
    CentreGUI (4);
    GUIOn (4);
      if (button==3) {
      GUIOff (4);}
        else { index=ListBoxGetSelected(4,0);
        RestoreGameSlot(savegameindex[index]);}
      
  if (interface == 5) {
    CentreGUI (5);
    GUIOn (5);
      if (button==2) { 
      GUIOff (5);}
      if (button==3) {
        index=ListBoxGetNumItems (5, 4);
        if (index<20) {
          GetTextBoxText (5, 1,text);
          GUIOff (5);
          SaveGameSlot (index+1,text);}
        else {
          index=ListBoxGetSelected (5, 4);
          GetTextBoxText (5, 1,text);
          GUIOff (5);
          SaveGameSlot(savegameindex[index],text); } 
       }


The two GUIs in question are set up like this:
  GUI No. 4 (Restore box):
    -Object 0: List Box
    -Object 1: Label
    -Object 2: Button (Restore)
    -Object 3: Button (Cancel)

  GUI No. 5 (Save box):
    -Object 0: Label
    -Object 1: Text Box
    -Object 2: Button (Cancel)
    -Object 3: Button (Save)
    -Object 4: List Box

Now here's what's not working. The GUIs pop up fine, but nothing works with them except the Cancel button on the Restore GUI (GUI 4). Not even the Cancel button on the Save GUI works!! Can someone PLEASE help?!?
I make music.

Gilbert

Well, since those scripts are in the interface_click() function (I suppose, and they should be there), I don't think the CentreGUI() and GUIOn() lines are necessary (as they should be called when you call up the GUI's already.
For the button not responding part, had you checked the properties of them and are sure that they're set to receive clicks? (Left click set to 'Run script')


Radiant

In addition to what Gilbot said, did you initialize the saved game listings? There's some function that does that, (forget what it's called) use it whenever you turn the relevant GUIs on.

BerserkerTails

Yeah, I have at the start of ther global_script:

string text;
int index;

You know, I think I may have just figured out the problem... PErhpas instead of the GUIOff command, I should use InterfaceOff...

I'll try that when I get home. Thanks for the help though!
I make music.

Pumaman

If you use the Match Brace feature on that script, you'll see that the entire "if (interface == 5)" block seems to be inside of the "if (interface == 4)" block, so it will never get called (unless it's just a typo in the code you posted, of course).

And yes, make sure you use ListBoxSaveGameList when you turn the GUI on.

BerserkerTails

#5
CJ, you are brilliant! Thank you SO MUCH! It's works now, perfectly! Time to polish up the actual GUIs now...

Oops, another problem... I'm trying to make it so if a save game is selected in the listbox, pressing the Save button will overwrite it. Here's the code I have SO far...

  if (interface == 5) {
    CentreGUI (5);
    GUIOn (5);
      ListBoxSetSelected (5, 4, -1);
      if (button==2) { 
      GUIOff (5);}
      if (button==3) {
        index=ListBoxGetNumItems (5, 4);
        if (index<20) {
          ListBoxGetItemText (5,4,ListBoxGetSelected(5, 4),sele);
          if (sele==-1){
          GetTextBoxText (5, 1,text);
          GUIOff (5);
          SaveGameSlot (index+1,text);}
        else {
          ListBoxGetItemText (5,4,ListBoxGetSelected(5,4),text);
          GUIOff (5);
          SaveGameSlot(savegameindex[index],text); }
        else {
          index=ListBoxGetSelected (5, 4);
          GetTextBoxText (5, 1,text);
          GUIOff (5);
          SaveGameSlot(savegameindex[index],text); } 
       }


Now I added a string sele; to the top of the Global_int... Now what? The problem is the line with ListBoxGetItemText (5,4,ListBoxGetSelected(5, 4),sele); on it. See, I'm trying to get the code to check whether there is a file selected. If there isn't, I want (sele== -1). But It can't get that... Please help!
I make music.

Gilbert

Just use ListBoxGetSelected (), and please remove/comment out the part enclosed by /* and */ (they'll reset the GUI's status whenever you click something on it, you only need them WHEN YOU ARE LAUNCHING THE GUI.

  if (interface == 5) {
/* remove this portion
    CentreGUI (5);
    GUIOn (5);
      ListBoxSetSelected (5, 4, -1);
*/
      if (button==2) { 
      GUIOff (5);}
      if (button==3) {
        sele = ListBoxGetSelected (5, 4);
        index=ListBoxGetNumItems (5, 4);
        if (index<20) {
          //ListBoxGetItemText (5,4,ListBoxGetSelected(5, 4),sele);
          if (sele==-1){
          GetTextBoxText (5, 1,text);
          GUIOff (5);
          SaveGameSlot (index+1,text);}
        else {
          ListBoxGetItemText (5,4,ListBoxGetSelected(5,4),text);
          GUIOff (5);
          SaveGameSlot(savegameindex[index],text); }
        else {
          index=ListBoxGetSelected (5, 4);
          GetTextBoxText (5, 1,text);
          GUIOff (5);
          SaveGameSlot(savegameindex[index],text); } 
       }

I didn't check much, maybe there're some other problems.

BerserkerTails

Still no dice... Error on the line with "sele = ListBoxGetSelected (5, 4);": Cannot assign to string; Use Str* functions instead.

Thanks for the help Gilbot... Just need a bit more...
I make music.

Gilbert

Because you SHOULD declare sele as int (you used text for string already), it will hold the position of the selected option (-1 if not selected).

BerserkerTails

I did it. After changeing sele to an int, and changing a few other things, it's working perfectly! Now for the easy stuff... Finishing the graphics for the GUIs, and enabling only the pointer cursor for the GUIs. Not the hardest things to do...

Thanks to eveyone who helped! This topic can be locked if any mods are following it's progress,  ;)
I make music.

Gilbert

Good to hear it's working. No need to lock, just let it rot. ;)

SMF spam blocked by CleanTalk