Author Topic: Custom Quit GUI  (Read 795 times)  Share 

00jon00

  • Man....I need pop tarts
    • I can help with AGS tutoring
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Custom Quit GUI
« on: 16 Mar 2004, 04:53 »
Ok, this is stupid...I've created a billion-well alot-of quit guis, and they all worked, this one when you click on any of the buttons they don't do anything??? What do I keep over looking lol? Here's the script..Smack me when you find my stupid mistake please 8):

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
      GUIOn(QUITGUI);
    else if (button == 9)    // about
      Display("Just Another Day[[Copyright (c) 2001-2005 Jonathan Hayes");
  }  // 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 == QUITGUI) {
     if (button == 0) {
       QuitGame (0);
     }
     if (button == 2) {
       GUIOff (QUITGUI);
     }
     if (button == 1) {
       Display("WHAT!? ARE YOU TRYING TO CHEAT!!! Save often");
       GUIOff (QUITGUI);
     }
      }    
  }

Oh, and that smiley-in the script-is supposed to be an 8...
« Last Edit: 16 Mar 2004, 23:06 by 00jon00 »

Scummbuddy

  • Mittens Knight
  • Give Stylish Confetti to BoZo - Wheee!
    • I can help with AGS tutoring
    •  
    • I can help with animation
    •  
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
Re:Custom Quit GUI
« Reply #1 on: 16 Mar 2004, 04:57 »
Edit your post, and right above the "post" button, there is a checkbox that you should tick if youre addind code, to get rid of that smiley

have you done "run script' on your buttons actions?
« Last Edit: 16 Mar 2004, 04:57 by Scummbuddy »
- 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

LordHart

  • Gitter Dun!
    • I can help with backgrounds
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • I can help with web design
    •  
  • LordHart worked on a game that was nominated for an AGS Award!
Re:Custom Quit GUI
« Reply #2 on: 16 Mar 2004, 04:58 »
Yeah, I'd say that smiley is screwing it up... :)

00jon00

  • Man....I need pop tarts
    • I can help with AGS tutoring
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re:Custom Quit GUI
« Reply #3 on: 16 Mar 2004, 05:07 »
Yeah, sorry I forgot about the adding code part.  Yes I made sure the buttons were set to 'run script'

Darth Mandarb

  • Evil Sith Lord
  • Mittens Vassal
  • AGS Baker
    • Lifetime Achievement Award Winner
    •  
  • Darth Mandarb worked on a game that was nominated for an AGS Award!
Re:Custom Quit GUI
« Reply #4 on: 16 Mar 2004, 09:33 »
I'm no scripting expert ...

But it appears there might be a lot of missing brackets.

you have this:
}
 else if (button == 5) { // use selected inventory
 if (character[ GetPlayerCharacter() ].activeinv >= 0)
 SetCursorMode(4);
}

try this instead:
}
 else if (button == 5) { // use selected inventory
 if (character[ GetPlayerCharacter() ].activeinv >= 0) {
 SetCursorMode(4);
}
}


I'm not sure though ... but that would be my guess.  All your code seems to be missing those brackets.

Also ... I'm not sure if QuitGame(0); shouldn't be Quit(0); instead.  But you may want to look into that too.

Hope it helps ...

~ d

Iceboty V7000a

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
    •  
Re:Custom Quit GUI
« Reply #5 on: 16 Mar 2004, 10:20 »
Well that makes no difference, darth, if you only need one line of code after the if condition, you don't really need the {}'s

actually the problem is:


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
      GUIOn(QUITGUI);
    else if (button == 9)    // about
      Display("Just Another Day[[Copyright (c) 2001-2005 Jonathan Hayes");
  }  // 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;
    }
 } // <-- ADD THIS ONE


    if (interface == QUITGUI) {
     if (button == 0) {
       QuitGame (0);
     }
     if (button == 2) {
       GUIOff (QUITGUI);
     }
     if (button == 1) {
       Display("WHAT!? ARE YOU TRYING TO CHEAT!!! Save often");
       GUIOff (QUITGUI);
     }
      }    
//  } <-- Delete this }



See the red and blue texts specifically. The main reason is that you didn't place the brackets correctly, so the "if (interface == QUITGUI) ..." part was inside of the " if (interface == INVENTORY)... " part.
« Last Edit: 16 Mar 2004, 10:25 by Gilbot V7000a »

Re:Custom Quit GUI
« Reply #6 on: 16 Mar 2004, 10:21 »
Quote
All your code seems to be missing those brackets.

Technically, if there's only one line of code, you don't need the brackets. But I also recommend adding them in case you decide to add something later.

Your problem is bracket-related, though:


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 == QUITGUI) {
      if (button == 0) {
         QuitGame (0);
      }
      if (button == 2) {
         GUIOff (QUITGUI);
      }
      if (button == 1) {
         Display("WHAT!? ARE YOU TRYING TO CHEAT!!! Save often");
         GUIOff (QUITGUI);
      }
   }
}


Just formatted it to show the logic. Do you see it?

EDIT: Meh, too late...
« Last Edit: 16 Mar 2004, 10:22 by strazer »

Darth Mandarb

  • Evil Sith Lord
  • Mittens Vassal
  • AGS Baker
    • Lifetime Achievement Award Winner
    •  
  • Darth Mandarb worked on a game that was nominated for an AGS Award!
Re:Custom Quit GUI
« Reply #7 on: 16 Mar 2004, 21:07 »
Oops ...

Man, I suck ;)

~ d

00jon00

  • Man....I need pop tarts
    • I can help with AGS tutoring
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re:Custom Quit GUI
« Reply #8 on: 16 Mar 2004, 23:13 »
Thanks guys...Gilbot V7000a, yours worked...I knew I missed something extremely stupid lol...It was late and I was tired...Thanks again guys