Author Topic: Save Game Dialog Issues  (Read 450 times)  Share 

BernieLaraemie

  • Round Hole. Square Peg. Steely Determination.
    • I can help with characters
    •  
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
Save Game Dialog Issues
« on: 26 Jul 2005, 04:57 »
I'm using AGS 2.7, and I've written a save game script off of Proskrito's MI2 template.  It's been upgraded, and it works, save for a few issues:

--label on Savetext GUI is always 1
--Will only save to slot 1

I figure it's a problem with lstSAVE/REST.Selectedindex, but I'm out of things to change.

Here is the script:

if (interface == SAVE) {
  int index;
  lstSAVE.SelectedIndex = index;
  if (button == 0) {gSave.Visible = false; //cancel
              gSavetext.Visible = false;
                              }
  if (button == 1) {int slist; //listbox
              StrFormat(buffer, "%d", index+1);
              lblNUM.SetText(buffer);
              if (GetSaveSlotDescription(index+100,buffer)==0) StrCopy(buffer,"");
              txtSAVE.SetText(buffer);
              slist=75+((index-GStopsaveitem)*(DEFAULT_FONT_HEIGHT+2));
              if (index<9) txtSAVE.SetPosition(12, 0);
             else txtSAVE.SetPosition(18, 0);
            gSavetext.SetPosition(79, slist);
            gSavetext.Visible = true;                                                            
   }
    if (button == 2 && index>=0) {   //save game                                    
txtSAVE.GetText(buffer);
gSave.Visible = false;                                          
gSavetext.Visible = false;
SaveGameSlot(index+100, buffer);
                                                   }



    if (button == 3){//scroll up
                               gSavetext.Visible = false;
                lstSAVE.SelectedIndex = -1;
          if (GStopsaveitem<5) GStopsaveitem=0;
                         else GStopsaveitem-=5;
          lstSAVE.TopItem = GStopsaveitem;
                              }

    if (button == 4 && GStopsaveitem<90){ //scroll down
            gSavetext.Visible = false;
            lstSAVE.SelectedIndex = -1;
              GStopsaveitem+=5;
              lstSAVE.TopItem = GStopsaveitem;
   }


}

if (interface == SAVETEXT){
      int index2;
      lstSAVE.SelectedIndex = index2;
     
if (button == 0){ //write save name
            txtSAVE.GetText(buffer);     
            gSave.Visible = false;
            gSavetext.Visible = false;
                                 SaveGameSlot(index2+100,buffer);
                                 }
    if (IsButtonDown(RIGHT)) gSavetext.Visible = false; //turn off GUI
 

}

 if (interface == LOAD) {
    if (button ==4) gLoad.Visible = false; //cancel
    if (button ==2){ //click on listbox item
            int index3;
            lstREST.SelectedIndex = index3;
            if (GetSaveSlotDescription(index3 + 100, buffer)==1) { //if saved games exist
            gLoad.Visible = false;
            RestoreGameSlot(index3+100);
        }
       }
   
    if (button == 0){ //scroll up
         if (GStopsaveitem<5) GStopsaveitem=0;
         else GStopsaveitem-=5;
         lstREST.TopItem = GStopsaveitem;
            }
    if (button == 1 && GStopsaveitem<90) { //scroll down
      GStopsaveitem+=5;
      lstREST.TopItem = GStopsaveitem;
     
    }
   
   

   
}

Any help is very appreciated, thank you.

~~Bernie
« Last Edit: 29 Jul 2005, 10:01 by BernieLaraemie »
~~~~~
"It doesn't matter whether something is true, just that it is believed." -- Jim Morrison
~~~~~
THIS SPACE FOR RENT

Iceboty V7000a

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
    •  
Re: Save Game Issues
« Reply #1 on: 26 Jul 2005, 06:29 »
I'm too lazy to check all the codes at the moment, but bear in mind that variables declared inside of a function are not initialized, so pairs of codes like below may generate unexpected results:
  int index;
  lstSAVE.SelectedIndex = index;
(It may even generate a crash if index is set to some out of range value when declared).

I'm too lazy, but try initialising the variables and see if that helps:

if (interface == SAVE) {
  int index=0;
  lstSAVE.SelectedIndex = index;
  if (button == 0) {gSave.Visible = false; //cancel
              gSavetext.Visible = false;
                              }
  if (button == 1) {int slist; //listbox
              StrFormat(buffer, "%d", index+1);
              lblNUM.SetText(buffer);
              if (GetSaveSlotDescription(index+100,buffer)==0) StrCopy(buffer,"");
              txtSAVE.SetText(buffer);
              slist=75+((index-GStopsaveitem)*(DEFAULT_FONT_HEIGHT+2));
              if (index<9) txtSAVE.SetPosition(12, 0);
             else txtSAVE.SetPosition(18, 0);
            gSavetext.SetPosition(79, slist);
            gSavetext.Visible = true;                                                            
   }
    if (button == 2 && index>=0) {   //save game                                    
txtSAVE.GetText(buffer);
gSave.Visible = false;                                          
gSavetext.Visible = false;
SaveGameSlot(index+100, buffer);
                                                   }



    if (button == 3){//scroll up
                               gSavetext.Visible = false;
                lstSAVE.SelectedIndex = -1;
          if (GStopsaveitem<5) GStopsaveitem=0;
                         else GStopsaveitem-=5;
          lstSAVE.TopItem = GStopsaveitem;
                              }

    if (button == 4 && GStopsaveitem<90){ //scroll down
            gSavetext.Visible = false;
            lstSAVE.SelectedIndex = -1;
              GStopsaveitem+=5;
              lstSAVE.TopItem = GStopsaveitem;
   }


}

if (interface == SAVETEXT){
      int index2=0;
                  lstSAVE.SelectedIndex = index2;
     
if (button == 0){ //write save name
            txtSAVE.GetText(buffer);     
            gSave.Visible = false;
            gSavetext.Visible = false;
                                 SaveGameSlot(index2+100,buffer);
                                 }
    if (IsButtonDown(RIGHT)) gSavetext.Visible = false; //turn off GUI
 

}

 if (interface == LOAD) {
    if (button ==4) gLoad.Visible = false; //cancel
    if (button ==2){ //click on listbox item
            int index3=0;
            lstREST.SelectedIndex = index3;
            if (GetSaveSlotDescription(index3 + 100, buffer)==1) { //if saved games exist
            gLoad.Visible = false;
            RestoreGameSlot(index3+100);
        }
       }
   
    if (button == 0){ //scroll up
         if (GStopsaveitem<5) GStopsaveitem=0;
         else GStopsaveitem-=5;
         lstREST.TopItem = GStopsaveitem;
            }
    if (button == 1 && GStopsaveitem<90) { //scroll down
      GStopsaveitem+=5;
      lstREST.TopItem = GStopsaveitem;
     
    }
   
   

   
}


BernieLaraemie

  • Round Hole. Square Peg. Steely Determination.
    • I can help with characters
    •  
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
Re: Save Game Issues
« Reply #2 on: 26 Jul 2005, 07:51 »
:(

Sorry Gilbot.  That had no effect.  Any more ideas from anyone?

~~Bernie
~~~~~
"It doesn't matter whether something is true, just that it is believed." -- Jim Morrison
~~~~~
THIS SPACE FOR RENT

Iceboty V7000a

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
    •  
Re: Save Game Issues
« Reply #3 on: 26 Jul 2005, 08:02 »
Hmmm maybe it's this problem, the SelectedIndex is changed to some fixed value, maybe the correct one is the otherway round:
if (interface == SAVE) {
  int index;
  index = lstSAVE.SelectedIndex;
  if (button == 0) {gSave.Visible = false; //cancel
              gSavetext.Visible = false;
                              }
  if (button == 1) {int slist; //listbox
              StrFormat(buffer, "%d", index+1);
              lblNUM.SetText(buffer);
              if (GetSaveSlotDescription(index+100,buffer)==0) StrCopy(buffer,"");
              txtSAVE.SetText(buffer);
              slist=75+((index-GStopsaveitem)*(DEFAULT_FONT_HEIGHT+2));
              if (index<9) txtSAVE.SetPosition(12, 0);
             else txtSAVE.SetPosition(18, 0);
            gSavetext.SetPosition(79, slist);
            gSavetext.Visible = true;                                                            
   }
    if (button == 2 && index>=0) {   //save game                                    
txtSAVE.GetText(buffer);
gSave.Visible = false;                                          
gSavetext.Visible = false;
SaveGameSlot(index+100, buffer);
                                                   }



    if (button == 3){//scroll up
                               gSavetext.Visible = false;
                lstSAVE.SelectedIndex = -1;
          if (GStopsaveitem<5) GStopsaveitem=0;
                         else GStopsaveitem-=5;
          lstSAVE.TopItem = GStopsaveitem;
                              }

    if (button == 4 && GStopsaveitem<90){ //scroll down
            gSavetext.Visible = false;
            lstSAVE.SelectedIndex = -1;
              GStopsaveitem+=5;
              lstSAVE.TopItem = GStopsaveitem;
   }


}

if (interface == SAVETEXT){
      int index2;
                  index2 = lstSAVE.SelectedIndex;
     
if (button == 0){ //write save name
            txtSAVE.GetText(buffer);     
            gSave.Visible = false;
            gSavetext.Visible = false;
                                 SaveGameSlot(index2+100,buffer);
                                 }
    if (IsButtonDown(RIGHT)) gSavetext.Visible = false; //turn off GUI
 

}

 if (interface == LOAD) {
    if (button ==4) gLoad.Visible = false; //cancel
    if (button ==2){ //click on listbox item
            int index3;
            index3 = lstREST.SelectedIndex;
            if (GetSaveSlotDescription(index3 + 100, buffer)==1) { //if saved games exist
            gLoad.Visible = false;
            RestoreGameSlot(index3+100);
        }
       }
   
    if (button == 0){ //scroll up
         if (GStopsaveitem<5) GStopsaveitem=0;
         else GStopsaveitem-=5;
         lstREST.TopItem = GStopsaveitem;
            }
    if (button == 1 && GStopsaveitem<90) { //scroll down
      GStopsaveitem+=5;
      lstREST.TopItem = GStopsaveitem;
     
    }
   
   

   
}



BernieLaraemie

  • Round Hole. Square Peg. Steely Determination.
    • I can help with characters
    •  
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
Re: Save Game Issues
« Reply #4 on: 26 Jul 2005, 08:21 »
That's actually what I had before, and it results in some really weird errors.  The label is always set to 0, it always writes to 1 and clicking on any number in the load list box will load that game.

~~Bernie
~~~~~
"It doesn't matter whether something is true, just that it is believed." -- Jim Morrison
~~~~~
THIS SPACE FOR RENT

Re: Save Game Issues
« Reply #5 on: 27 Jul 2005, 07:27 »
bear in mind that variables declared inside of a function are not initialized

They are, as of AGS v2.7

BernieLaraemie

  • Round Hole. Square Peg. Steely Determination.
    • I can help with characters
    •  
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
Re: Save Game Issues
« Reply #6 on: 27 Jul 2005, 07:37 »
Is that why my script isn't working?  I've racked my brain and I'm really not sure what to do with it.

~~Bernie
~~~~~
"It doesn't matter whether something is true, just that it is believed." -- Jim Morrison
~~~~~
THIS SPACE FOR RENT

Re: Save Game Issues
« Reply #7 on: 27 Jul 2005, 07:49 »
I'm sure it's unrelated, I just wanted to correct Gilbert's statement.

BernieLaraemie

  • Round Hole. Square Peg. Steely Determination.
    • I can help with characters
    •  
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
Re: Save Game Issues
« Reply #8 on: 28 Jul 2005, 00:15 »
Ah.

Not another mystery solved, then.

~~Bernie
~~~~~
"It doesn't matter whether something is true, just that it is believed." -- Jim Morrison
~~~~~
THIS SPACE FOR RENT

BernieLaraemie

  • Round Hole. Square Peg. Steely Determination.
    • I can help with characters
    •  
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
Re: Save Game Issues [SOLVED]
« Reply #9 on: 29 Jul 2005, 04:38 »
Erm, why is this marked solved?  It hasn't been.

~~Bernie
~~~~~
"It doesn't matter whether something is true, just that it is believed." -- Jim Morrison
~~~~~
THIS SPACE FOR RENT

TerranRich

  • The Mystery Begins WHENEVER, Okay? ;)
    • I can help with characters
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
    • I can help with web design
    •  
  • TerranRich worked on a game that was nominated for an AGS Award!
Re: Save Game Issues (Hasn't been solved)
« Reply #10 on: 29 Jul 2005, 06:18 »
I saw the word solved and I thought it was solved. Don't be ambiguous! ;) :P

BernieLaraemie

  • Round Hole. Square Peg. Steely Determination.
    • I can help with characters
    •  
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
Re: Save Game Issues (Hasn't been solved)
« Reply #11 on: 29 Jul 2005, 10:00 »
I shall keep that in mind ;)

~~Bernie
~~~~~
"It doesn't matter whether something is true, just that it is believed." -- Jim Morrison
~~~~~
THIS SPACE FOR RENT