Whats wrong with this script?

Started by Moox, Mon 13/12/2004 05:09:57

Previous topic - Next topic

Moox

I get an error that says unexpected if on the line following the
#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE

Well here is the global script
Code: ags
// main global script file
string text;
 
int index;
 

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
  // called when the game starts, before the first room is loaded
}
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  // put anything you want to happen every game cycle here
}
#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE


function show_inventory_window () {
  // This demonstrates both types of inventory window - the first part is how to
  // show the built-in inventory window, the second part uses the custom one.
  // Un-comment one section or the other below.
  
  // ** DEFAULT INVENTORY WINDOW
  InventoryScreen();
/*  
  // ** CUSTOM INVENTORY WINDOW
  GUIOn (INVENTORY);  
  // switch to the Use cursor (to select items with)
  SetCursorMode (MODE_USE);
  // But, override the appearance to look like the arrow
  SetMouseCursor (6);
*/
}

#sectionstart on_key_press  // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) {
  // called when a key is pressed. keycode holds the key's ASCII code
  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
  if (keycode==17)  QuitGame(1);   // Ctrl-Q
  if (keycode==363) SaveGameDialog();   // F5
  if (keycode==365) RestoreGameDialog();  // F7
  if (keycode==367) RestartGame();  // F9
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==9)   show_inventory_window();  // Tab, show inventory

  if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode==22)  Debug(1,0);  // Ctrl-V, version
  if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room
  
}
#sectionend on_key_press  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(int button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button==LEFT) {
    ProcessClick(mouse.x, mouse.y, GetCursorMode() );
  }
  else {   // right-click, so cycle cursor
    SetNextCursorMode();
  }
}
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart interface_click  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
  if (interface == ICONBAR) {
    SetCursorMode(6);
    if (button == 4) {  // show inventory
      SetCursorMode (MODE_USE);
      GUIOn(1);
    }
    else if (button == 7)    // save game
      GUIOn(4);
    else if (button == 5)   // load game
      GUIOn(3);
    else if (button == 6)   // quit
      GUIOn(2);
    else if (button == 3)   // interact
      SetCursorMode(2);
    else if (button == 1)   // look
      SetCursorMode(1);
    else if (button == 2)   // walk
      SetCursorMode(0);
    else if (button == 0)   // talk
      SetCursorMode(3);
  }  // 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 == QUIT) {
    if (button == 0) {  // no
      GUIOff(2);
     }
    if (button == 1) {  // yes
      QuitGame(0);
      }
    }
  
}
#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE
if (interface==3) {
 // if Restore interface
 if (button==0) {
 // if cancel is pressed
 InterfaceOff(3);
 // Close interface 
 else { index=ListBoxGetSelected(3,1);
 // else get the selected game
 RestoreGameSlot(savegameindex[index]);}
 // restore the game
 }
}
 if (interface==4) {
 // if save interface
 if (button==1) {
 // if enter is pressed  
 index=ListBoxGetNumItems(4,0);
 // Count saved games  
 if (index<20) {
 // if less than 20
 GetTextBoxText(4,2,text);
 // Get the typed text
 InterfaceOff(4);
 // Close interface
 SaveGameSlot(index+1,text); }
 // Save game (text as description)
else {
 // if saved games are 20
 index=ListBoxGetSelected(4,0);
 // Get the selected save game
 GetTextBoxText(4,2,text);
 // Get the typed text 
 InterfaceOff(4);
 // Close the interface
 SaveGameSlot(savegameindex[index],text); }
 // Overwrite the selected game
 }
 if (button==3) { 
InterfaceOff(1);
 // if cancel is pressed close interface
}

Scummbuddy

Quote from: LostTraveler on Mon 13/12/2004 05:09:57
Code: ags

#sectionend interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
if (interface==3) 
{
 // if Restore interface
Ã,  Ã,  Ã, if (button==0) 
Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  // if cancel is pressed
Ã,  Ã,  Ã,  Ã,  InterfaceOff(3);
Ã,  Ã,  Ã,  Ã,  // Close interface 
Ã,  Ã,  Ã,  else 
Ã,  Ã,  Ã, { 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  index=ListBoxGetSelected(3,1);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // else get the selected game
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  RestoreGameSlot(savegameindex[index]);
Ã,  Ã,  Ã,  }
 // restore the game
}


} ??    <---------------- I think this goes at the very bottom.



if (interface==4) 
{
Ã,  Ã,  Ã,  // if save interface
Ã,  Ã,  Ã,  if (button==1) 
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if enter is pressedÃ,  
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, index=ListBoxGetNumItems(4,0);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Count saved gamesÃ,  
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  if (index<20) 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // if less than 20
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, GetTextBoxText(4,2,text);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Get the typed text
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, InterfaceOff(4);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Close interface
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SaveGameSlot(index+1,text); 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, }
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Save game (text as description)
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, else 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, { 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if saved games are 20
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  index=ListBoxGetSelected(4,0);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Get the selected save game
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  GetTextBoxText(4,2,text);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Get the typed text 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  InterfaceOff(4);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Close the interface
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SaveGameSlot(savegameindex[index],text); 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã, // Overwrite the selected game
Ã,  Ã,  Ã,  Ã, }

Ã,  Ã,  Ã,  Ã,  if (button==3)
Ã,  Ã,  Ã,  Ã, { 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  InterfaceOff(1);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if cancel is pressed close interface
Ã,  Ã,  Ã,  Ã,  }

                       <------------------This is the very bottom, where that brace should go.
[/quote]
- 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

strazer

I haven't bothered checking the whole script, but at least one brace is missing:

...
if (interface==3)
{
// if Restore interface
     if (button==0)
    {
        // if cancel is pressed
        InterfaceOff(3);
        // Close interface
    }
      else
     {
...

Ashen

Am I missing something, or should all the code after #sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE (if (interface == 3) { ..... } and if (interface == 4) { ..... } be in interface_click? As it is, it's not actually attached to any function, which may be why it's an 'unexpected if' error.
I know what you're thinking ... Don't think that.

Radiant

Try using the 'match brace' option from the editor's menu. A lot.

SMF spam blocked by CleanTalk