Unexpected if [SOLVED]

Started by ., Sun 03/04/2005 17:33:47

Previous topic - Next topic

.

ok this is my global scrip part for a siple GUI

function interface_click(int interface, int button) {
if (interface == GUI1) {   
    if (button == 1) {
      SetCursorMode(MODE_LOOK);
    }
    if (button == 2) {
      SetCursorMode(MODE_USE);
    }
    if(button==3) {
      SetCursorMode(MODE_USEINV);
    }
    if(button==4) {
      GUIOn(Q);
    }
    if(button==5)
       GUIOff(GUI1);
    }
  }
if (interface== Q) {
    if (button==0) {
       GUIOff(Q);
    }
    if (button==1) {
       QuitGame(0);
    }
  }   
if (interface==GUI2) {
  if(button==0) {
    SetCursorMode(MODE_PICKUP);
  }
  if(button==1) {
    SetCursorMode(MODE_LOOK);
  }
  if(button==2) {
    GUIOn(GUI1);
  }
  }

problem when i try to test game there is error un expected "if" on line 91 (its where the line is  if(interface==Q) {
I cant undrestand what is the f***ing problem?

Ashen

#1
Line 89 (   if(button==5)) is missing a {, so line 90 effectively closes interface_click, giving the error. Add the { to line 89, and it should be OK.

Also, if there's only one line, you don't actually need the braces:
Code: ags


function interface_click(int interface, int button) {
  if (interface == GUI1) {   
    if (button == 1) SetCursorMode(MODE_LOOK);
    if (button == 2) SetCursorMode(MODE_USE);
    // Etc
    }
  if (interface== Q) {
    //etc
  }
}

Would work just as well.
I know what you're thinking ... Don't think that.

.

#2
Thanks a lot
EDIT: i tryd it and it works now

SMF spam blocked by CleanTalk