I want to open/close new GUI, after pressing a button. Code:
if(button==16){
if(IsGUIOn(1)==1){
GUIOff(1);}
else {GUIOn(1);}}
I checkedÃ, it many times, there is chosen right button in the right GUI, GUI wchich I want to open exists, in button preferences runs script after left clicking it is checked, GUI with button is clickable...
And it still don't work. Why?
First off, you may want to make your code more readable by indenting it properly and placing brackets more prominently:
if (button == 16) {
if(IsGUIOn(1) == 1) {
GUIOff(1);
}
else {
GUIOn(1);
}
}
Since you don't need the brackets if you only execute one command after the condition, you can compact that to:
if (button == 16) {
if(IsGUIOn(1)) GUIOff(1);
else GUIOn(1);
}
The way you have it now, it's easy to miss opening/closing brackets IMO.
But from a technical standpoint, I can see nothing wrong with it and you eliminated most common causes.
It would help if you posted the surrounding code, for example your whole interface_click function.
if (interface==STATUS){
Ã, if(button==0){SetPlayerCharacter(2);}
if (button==1){SetPlayerCharacter(3);}
if (button == 16) {
Ã, Ã, if(IsGUIOn(1)) GUIOff(1);
Ã, Ã, else GUIOn(1);}
Ã, }
Rest of GUIs are still standard AGS templates
EDIT: Oh, solved already. I just have not set GUI 1 visibility to popup modal