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...
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?
Yeah, I'd say that smiley is screwing it up... :)
Yeah, sorry I forgot about the adding code part. Yes I made sure the buttons were set to 'run script'
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
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.
QuoteAll 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...
Oops ...
Man, I suck ;)
~ d
Thanks guys...Gilbot V7000a, yours worked...I knew I missed something extremely stupid lol...It was late and I was tired...Thanks again guys