I need some help!

Started by piraatlife4me, Fri 12/12/2003 06:05:08

Previous topic - Next topic

piraatlife4me

Hey AGS land! I am in need of some help with my code for my main icon bar.  I had before created my own custom quit screen It worked fine everything was going swell untill I tried to add a custom save and restore screen to it.  Now the interfaces all will pop up on the screen but the buttons dont work for some apparent reason.  Oh yeah and the save and load screens pop up but they don't really work either. I have mad sure to enable the left click mode to (Run Script) in the AGS GUI interface I think some of my brackets are put in the wrong places.  Can anyone proof read this and tell me if it looks funky.  Or if anyone has any suggestions please feel free to let me know ok.   Here is my code

function interface_click(int interface, int button) {
 if (interface == ICONBAR) {
   if (button == 4) {  // show inventory
     show_inventory_window();
   }
   else if (button == 4) {   // use selected inventory
     if (character[ GetPlayerCharacter() ].activeinv >= 0)
       SetCursorMode(4);
   }
   else if (button == 5) {     // save game
  GUIOn(7);
  }
  else if (button == 6) {  // load game
  GUIOn(8);
  }
  else if(button == 7) { //
    GUIOn(3);
     int quit_message = Random(6);
     if(quit_message==0) {
     SetLabelText(3, 1, "Oh I'm sorry! A Little Too Much?");
     SetButtonPic(3, 2, 1, 386);
     }
     else if (quit_message==1) {
     SetLabelText(3, 1, "Once a Poser! Always a Poser!");
     SetButtonPic(3, 2, 1, 386);
     }
      else if (quit_message==2) {
     SetLabelText(3, 1, "Signing up are we?");
     SetButtonPic(3, 2, 1, 389);
     }
     else if (quit_message==3) {
     SetLabelText(3, 1, "Crashed Out!");
     SetButtonPic(3, 2, 1, 390);
     }
     else if (quit_message==4) {
     SetLabelText(3, 1, "Going to Work?");
     SetButtonPic(3, 2, 1, 388);
     }
     else if (quit_message==5) {
     SetLabelText(3, 1, "Bitchin out?");
     SetButtonPic(3, 2, 1, 387);
     }
     else if (quit_message==5) {
     SetLabelText(3, 1, "Looking for a way out?");
     SetButtonPic(3, 2, 1, 391);
     }
   }
if (interface == QUITGAME) {
  if (button == 3) {  
      GUIOff(3);
   }
   if (button == 0) {
      QuitGame(0);    
 }
}
if (interface==SAVEGAME) {
SetMouseCursor(8);  
if (button==3) {
index=ListBoxGetNumItems(7,5);   // Count saved games
if (index<9) {
GetTextBoxText(7,2,text);       // Get the typed text
InterfaceOff(7);                // Close interface
SaveGameSlot(index+1,text); }  // Save game (text as description)
else {                          // if saved games are 20
index=ListBoxGetSelected(7,5);    // Get the selected save game
GetTextBoxText(7,2,text);         // Get the typed text
InterfaceOff(7);                 // Close the interface
SaveGameSlot(savegameindex
[index],text); }           // Overwrite the selected game
}
if (button==4) InterfaceOff(7);
}
}
if (interface == INVENTORY) {       // They clicked a button on the Inventory GUI  
   if (button == 1) {           // They pressed SELECT, so switch to the Get cursor
     SetCursorMode (MODE_USE);       // But, override the appearance to look like the arrow
     SetMouseCursor (6);
   }
   else if (button == 2) {
     // They pressed LOOK, so switch to that mode
     SetActiveInventory(-1);
     SetCursorMode(MODE_LOOK);  
   }
   else if (button == 3) {
     // They pressed the OK button, close the GUI
     GUIOff (INVENTORY);
     SetDefaultCursor();
   }
   else if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
     // scroll down
     game.top_inv_item = game.top_inv_item + game.items_per_line;
   }
   else if ((button == 5) && (game.top_inv_item > 0)){
     // scroll up
     game.top_inv_item = game.top_inv_item - game.items_per_line;
 }
}
}
Like I said a bracket or two must be out of place but I need some help locating it
thanks

Daniel
Winebarger

P.S I am having trouble with my custom save and restore screen? They look good and all but they don't save and they don't cancel out.  I need help with that as well (just thought I would add this on)?

After

#1
SetButtonPic(3, 2, 1, 391);
}
}
}//insert this
if (interface == QUITGAME) {

/*etc*/

if (button==4) InterfaceOff(7);
}
}//remove this
if (interface == INVENTORY) { // They clicked a button on the Inventory GUI


And what's this? ...
Quote from: piraatlife4me on Fri 12/12/2003 06:05:08
Code: ags

function interface_click(int interface, int button) {
  if (interface == ICONBAR) {
    if (button == 4) {  // show inventory
      show_inventory_window();
    }
    else if (button == 4) {   // use selected inventory
      if (character[ GetPlayerCharacter() ].activeinv >= 0)
        SetCursorMode(4);
    } 

else if (button == 4) {   // use selected inventory
will never happen because you've already caught it with if (button == 4) {  // show inventory.

Maybe you should check your button numbers.

Scummbuddy

Please read the rules. CJ probably thought you were on fire.  (Make suitable subject titles.)
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

piraatlife4me

Sorry about that!  Its serious but not that serious!  

Daniel winebarger

piraatlife4me

Hey thanks alot after!  I tried it and it totally fixed my problem so thanks.  One other question though is the object number the same as the button number on each individual gui?  Like how do you define the button number is it labaled by the object number or is it different?If I knew that I could fix my save restore problem
thanks again

Daniel
Winebarger

After

Yes, the object number is used for all of those GUI functions.
Notice how the GUI functions in the manual always refer to the object, rather the the specific type of object relevant to the function.

So instead of thinking do function with button-#, you could think of it as do button-function with object-#.

TerranRich

Another broken rule: double posting.

Wow, you're on a role tonight! :P
Status: Trying to come up with some ideas...

After

Quote from: terranRICH on Sun 14/12/2003 06:43:35
Another broken rule: double posting.

Wow, you're on a role tonight! :P
Way to exemplify the need for rules.

Scummbuddy

Well, in truth, they were over 5 hours apart, so its alright... but the subject title is going too far.  ;)
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

SMF spam blocked by CleanTalk