Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: viktor on Mon 02/08/2004 21:26:05

Title: walking- solved
Post by: viktor on Mon 02/08/2004 21:26:05
Hy. I'm back. I hawe a little problem. I hawe this monkey island/dott  stile gui and it dosn't contain a walk to option. The game realy needs that now dosn't it. Here are all the scripts:

  // this GUI system uses GlobalInt 80 to store which of the extended
  // modes is in use (close, give, push, pull, etc)

  if (interface == 0) {
    if (button == 8) {   // give
      SetGlobalInt(80,2);
      }
    if (button == 1) {   // open
      SetCursorMode(8);
      SetGlobalInt(80,3);
      }
    if (button == 2) {   // look at
      SetCursorMode(1);
      SetGlobalInt(80,8);
      }
    if (button == 3) {   // use
      SetCursorMode(2);
      SetGlobalInt(80,7);
      }
    if (button == 4) {   // close
      SetCursorMode(8);
      SetGlobalInt(80,1);
      }   
    if (button == 5) {   // push
      SetCursorMode(8);
      SetGlobalInt(80,4);
      }
    if (button == 6) {   // take
      SetCursorMode(5);
      SetGlobalInt(80,6);
      }
    if (button == 7) {   // talk to
      SetCursorMode(3);
      SetGlobalInt(80,9);
      }
    if (button == 8) {   // pull
      SetCursorMode(8);
      SetGlobalInt(80,5);
      }

    if ((button == 10) & (game.top_inv_item < game.num_inv_items - 7))
      game.top_inv_item = game.top_inv_item + 4;
    if ((button == 9) & (game.top_inv_item > 0))
      game.top_inv_item = game.top_inv_item - 4;
    }


I would like to replace the GIVE option with a WALKT TO option. What do I hawe to change?
Title: Re: walking
Post by: Ashen on Tue 03/08/2004 15:35:01
Ã,  Ã, if (button == 8 ) {Ã,  Ã, // give
Ã,  Ã,  Ã,  SetGlobalInt(80,2);
Ã,  Ã,  Ã,  }

to

Ã,  Ã, if (button == 8 ) {Ã,  Ã, // walk
Ã,  Ã,  Ã,  SetCursorMode (0);
Ã,  Ã,  Ã,  }

I think, but I'm not really familiar with how that GUI works. I did notice, however, that button 8 sets both 'give' and 'pull' modes. Should one of them beÃ,  'if (button == 0) {' ? Hope this helps.
Title: Re: walking
Post by: viktor on Tue 03/08/2004 18:20:10
QuoteI think, but I'm not really familiar with how that GUI works. I did notice, however, that button 8 sets both 'give' and 'pull' modes. Should one of them be  'if (button == 0) {' ? Hope this helps.

Hm...
I didn't notice that before. Thanks for warning me. You see I downloaded this GUI from the net so I'm not realy shure why it is set up this way.
Title: Re: walking
Post by: viktor on Tue 03/08/2004 18:28:33
it dosn't work...
Title: Re: walking
Post by: Proskrito on Tue 03/08/2004 21:11:54
QuoteYou see I downloaded this GUI from the net so I'm not realy shure why it is set up this way.
if its lucasfans monkey 2 template, i think you had to right click to get "walk" mode, but anyways, do as ashen says and it should work.
Title: Re: walking
Post by: viktor on Wed 04/08/2004 09:34:51
Well it should but it dosn't.

here is the problem:
(http://www.2dadventure.com/ags/problem_!.png)

and here is the main script:
// main global script file

#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) {
// this GUI system uses GlobalInt 80 to store which of the extended
  // modes is in use (close, give, push, pull, etc)

  if (interface == 0) {
     if (button == 8 ) {   // walk
      SetCursorMode (0);
      }
    if (button == 1) {   // open
      SetCursorMode(8);
      SetGlobalInt(80,3);
      }
    if (button == 2) {   // look at
      SetCursorMode(1);
      SetGlobalInt(80,8);
      }
    if (button == 3) {   // use
      SetCursorMode(2);
      SetGlobalInt(80,7);
      }
    if (button == 4) {   // close
      SetCursorMode(8);
      SetGlobalInt(80,1);
      }   
    if (button == 5) {   // push
      SetCursorMode(8);
      SetGlobalInt(80,4);
      }
    if (button == 6) {   // take
      SetCursorMode(5);
      SetGlobalInt(80,6);
      }
    if (button == 7) {   // talk to
      SetCursorMode(3);
      SetGlobalInt(80,9);
      }
    if (button == 8) {   // pull
      SetCursorMode(8);
      SetGlobalInt(80,5);
      }

    if ((button == 10) & (game.top_inv_item < game.num_inv_items - 7))
      game.top_inv_item = game.top_inv_item + 4;
    if ((button == 9) & (game.top_inv_item > 0))
      game.top_inv_item = game.top_inv_item - 4;
    }

#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE

Title: Re: walking
Post by: Gilbert on Wed 04/08/2004 09:45:58
You missed one } at the end of interface_click at least, try adding that first.
Title: Re: walking
Post by: viktor on Wed 04/08/2004 09:58:41
I checked and can't find the part where I mised it. But howcome it's mising now? Before I added the walk to part it worked fine...
Title: Re: walking
Post by: Gilbert on Wed 04/08/2004 10:04:22
Just add the } as mentioned.

#sectionstart interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
// this GUI system uses GlobalInt 80 to store which of the extended
Ã,  // modes is in use (close, give, push, pull, etc)

Ã,  if (interface == 0) {
Ã,  Ã,  Ã, if (button == 8 ) {Ã,  Ã, // walk
Ã,  Ã,  Ã,  SetCursorMode (0);
Ã,  Ã,  Ã, Ã,  }
Ã,  Ã,  if (button == 1)Ã,  {Ã,  Ã, // open
Ã,  Ã,  Ã,  SetCursorMode(8);
Ã,  Ã,  Ã,  SetGlobalInt(80,3);
Ã,  Ã,  Ã, Ã,  }
Ã,  Ã,  if (button == 2)Ã,  {Ã,  Ã, // look at
Ã,  Ã,  Ã,  SetCursorMode(1);
Ã,  Ã,  Ã,  SetGlobalInt(80,8);
Ã,  Ã,  Ã, Ã,  }
Ã,  Ã,  if (button == 3)Ã,  {Ã,  Ã, // use
Ã,  Ã,  Ã,  SetCursorMode(2);
Ã,  Ã,  Ã,  SetGlobalInt(80,7);
Ã,  Ã,  Ã, Ã,  }
Ã,  Ã,  if (button == 4)Ã,  {Ã,  Ã, // close
Ã,  Ã,  Ã,  SetCursorMode(8);
Ã,  Ã,  Ã,  SetGlobalInt(80,1);
Ã,  Ã,  Ã, Ã,  }
Ã,  Ã,  if (button == 5)Ã,  {Ã,  Ã, // push
Ã,  Ã,  Ã,  SetCursorMode(8);
Ã,  Ã,  Ã,  SetGlobalInt(80,4);
Ã,  Ã,  Ã, Ã,  }
Ã,  Ã,  if (button == 6)Ã,  {Ã,  Ã, // take
Ã,  Ã,  Ã,  SetCursorMode(5);
Ã,  Ã,  Ã,  SetGlobalInt(80,6);
Ã,  Ã,  Ã, Ã,  }
Ã,  Ã,  if (button == 7)Ã,  {Ã,  Ã, // talk to
Ã,  Ã,  Ã,  SetCursorMode(3);
Ã,  Ã,  Ã,  SetGlobalInt(80,9);
Ã,  Ã,  Ã, Ã,  }
Ã,  Ã,  if (button == 8)Ã,  {Ã,  Ã, // pull
Ã,  Ã,  Ã,  SetCursorMode(8);
Ã,  Ã,  Ã,  SetGlobalInt(80,5);
Ã,  Ã,  Ã, Ã,  }

Ã,  Ã,  if ((button == 10) & (game.top_inv_item < game.num_inv_items - 7))Ã,  game.top_inv_item = game.top_inv_item + 4;
Ã,  Ã,  if ((button == 9) & (game.top_inv_item > 0))Ã,  Ã,  game.top_inv_item = game.top_inv_item - 4;
Ã,  Ã,  }
} //<-- Add this back
#sectionend interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
Title: Re: walking
Post by: Proskrito on Wed 04/08/2004 12:17:05
and also, instead of:

if (interface == 0) {
     if (button == 8 ) {   // walk
      SetCursorMode (0);
       }

i think you have to write:

if (interface == 0) {
     if (button == 0 ) {   // walk
      SetCursorMode (0);
       }

because button 8 seems to be used for pull in you script
Title: Re: walking
Post by: viktor on Wed 04/08/2004 12:54:49
Ok. Now It works. THANKS! I hawe a nothr question with the same GUI though. When I go over the hotspot I would like the name of that hotspot to be diplayed. What do I hawe to add to the GUI and the script to make this work
Title: Re: walking
Post by: Ashen on Wed 04/08/2004 14:30:35
You just need to add a label on the GUI and set its text to @OVERHOTSPOT@
Title: Re: walking
Post by: viktor on Wed 04/08/2004 14:34:46
Quote from: Ashen on Wed 04/08/2004 14:30:35
You just need to add a label on the GUI and set its text to @OVERHOTSPOT@

Oh? Cool. Didn't know it was so easy. Thanks a bunch.