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?
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.
Is the "Run Script" option selected for button 0? Check at the button's properties.
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
upload the game files or gui
Did you try what I said? Did the Display() message appeaer?
ya, it didn't do anything at all, no message. i even removed all other commands and put just the display and nothing happened
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?
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
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
thanks very much! i see my problem now, my scripting is still pretty sketchy