Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: on Mon 19/07/2004 17:09:20

Title: GUIOn button
Post by: on Mon 19/07/2004 17:09:20
i looked all over the site, i surfed the forums and everything but i cannot spot what is wrong with my script here. all i want is a gui to turn on when i press a button on another gui. so my script looks like this:

if (interface == 3) {
  if (button == 0) {
   GUIOn(4);}
}

GUI 3 is clickable, i have the button set to run script, GUI 4 is a popop modal, all this script is in the function interface_click but i cannot figure out why it won't work. could it be something to do with how i have GUI 3 set to be persistent?
Title: Re: GUIOn button
Post by: Pumaman on Mon 19/07/2004 20:20:40
Does GUI 3 cover up GUI 4, so you wouldn't be able to see it?

The other thing to try is putting a Display command just before GUIOn, so you can see if its getting called.
Title: Re: GUIOn button
Post by: Skio on Mon 19/07/2004 21:07:00
Is the "Run Script" option selected for button 0? Check at the button's properties.
Title: Re: GUIOn button
Post by: on Tue 20/07/2004 03:17:24
yes, thats why i can;t figure it out, i got everything so it should work (all the common problems r fixed) but it doesn;t work. i listed everything i have done in the first post. its strange
Title: Re: GUIOn button
Post by: Moox on Tue 20/07/2004 04:31:29
upload the game files or gui
Title: Re: GUIOn button
Post by: Pumaman on Tue 20/07/2004 21:58:33
Did you try what I said? Did the Display() message appeaer?
Title: Re: GUIOn button
Post by: on Fri 23/07/2004 01:23:25
ya, it didn't do anything at all, no message. i even removed all other commands and put just the display and nothing happened
Title: Re: GUIOn button
Post by: Gilbert on Fri 23/07/2004 02:31:59
I think it can as well be some nesting errors in the script causing that part not working. Can you post the whole GUI script here?
Title: Re: GUIOn button
Post by: on Fri 23/07/2004 04:34:05
function interface_click(int interface, int button) {
  if (interface == ICONBAR) {
    if (button == 4) {  // show inventory
      show_inventory_window();
    }
    else if (button == 5) {   // use selected inventory
      if (character[ GetPlayerCharacter() ].activeinv >= 0)
        SetCursorMode(4);
    }
    else if (button == 6)    // save game
      SaveGameDialog();
    else if (button == 7)   // load game
      RestoreGameDialog();
    else if (button == 8)   // quit
      QuitGame(1);
    else if (button == 9)    // about
      Display("Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2003 Chris Jones");
  }  // end if interface ICONBAR

  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);
    }
   
    if (button == 2) {
      // They pressed LOOK, so switch to that mode
      SetActiveInventory(-1);
      SetCursorMode(MODE_LOOK); 
    }
    if (button == 3) {
      // They pressed the OK button, close the GUI
      GUIOff (INVENTORY);
      SetDefaultCursor();
    }

    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;
    }
    if ((button == 5) && (game.top_inv_item > 0)){
      // scroll up
      game.top_inv_item = game.top_inv_item - game.items_per_line;
    }
 
if (interface == 3) {
  if (button == 0) {
GUIOn(4);}
}
}
}


i am thinking it must be something wrong in there. i am also just doing this in a test game so i can do anything without hurting the real one (i am gonna make my guis, then copy them over after i get them working) so feel free to rip away at whatever u want
Title: Re: GUIOn button
Post by: Gilbert on Fri 23/07/2004 04:42:09
Yeah it's a scripting mistake, you put the if (interface==3)... part inside the INVENTORY GUI portions, making it never working.


function interface_click(int interface, int button) {
  if (interface == ICONBAR) {
    if (button == 4) {  // show inventory
      show_inventory_window();
    }
    else if (button == 5) {   // use selected inventory
      if (character[ GetPlayerCharacter() ].activeinv >= 0)
        SetCursorMode(4);
    }
    else if (button == 6)    // save game
      SaveGameDialog();
    else if (button == 7)   // load game
      RestoreGameDialog();
    else if (button == 8)   // quit
      QuitGame(1);
    else if (button == 9)    // about
      Display("Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2003 Chris Jones");
  }  // end if interface ICONBAR

  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);
    }
   
    if (button == 2) {
      // They pressed LOOK, so switch to that mode
      SetActiveInventory(-1);
      SetCursorMode(MODE_LOOK); 
    }
    if (button == 3) {
      // They pressed the OK button, close the GUI
      GUIOff (INVENTORY);
      SetDefaultCursor();
    }

    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;
    }
    if ((button == 5) && (game.top_inv_item > 0)){
      // scroll up
      game.top_inv_item = game.top_inv_item - game.items_per_line;
    }
  } //end INVENTORY
if (interface == 3) {
  if (button == 0) {
GUIOn(4);}
}
}
//} <-- remove this

Title: Re: GUIOn button
Post by: on Mon 26/07/2004 05:30:07
thanks very much! i see my problem now, my scripting is still pretty sketchy