Setting Up Properties for INteractions

Started by rtf, Thu 08/04/2004 03:04:08

Previous topic - Next topic

rtf

Ok, I searched through the forums and help file, and I found stuff for it, but I still don't get it.

How do I make it so that if I Right-CLick on something, then the character looks at it, and if I left click soemthing, the player Talks/Uses it, much like many games (The Uncertainty Machine, Bestowers of Eternity) do.

I know it has spmething to do with the custom properties schema, but I just don't understand how to fit it to my liking.


Thanks for the hlep
I fail at art.

Scorpiorus

You need to tweak your on_mouse_click() function, like:

first, an extra function:
function ProcessClickSpecial(int x, int y, int cursor_mode, int default_mode) {
   if (IsInteractionAvailable(x, y, cursor_mode)) ProcessClick(x, y, cursor_mode);
   else ProcessClick(x, y, default_mode);
}


What does it do? When you call the function it checks whether the interaction at specified co-ordinates is available. If it is then it processclick with cursor_mode, if not then with default_mode.


Next, the on_mouse_click() one:
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==RIGHT) {
      // if player has an item then unselect:
      if (character[GetPlayerCharacter()].activeinv != -1) SetActiveInventory(-1);
      // otherwise process look or walk:
      else ProcessClickSpecial(mouse.x, mouse.y, MODE_LOOK, MODE_WALK);
   } 
   else if (button==LEFT) {
      // if player has an item then try to use it:
      if (character[GetPlayerCharacter()].activeinv != -1)
         ProcessClickSpecial(mouse.x, mouse.y, MODE_USEINV, MODE_WALK);
      // otherwise just interact as usual:
      else ProcessClickSpecial(mouse.x, mouse.y, MODE_USE, MODE_WALK);
   }

   // handling inventory clicks: (Handle inventory clicks in script must be on!)
   else if (button==LEFTINV) { //for left inv. click:
      // select the item player has clicked on
      SetActiveInventory(game.inv_activated);
   }
   else if (button==RIGHTINV) { //for right inv. click:
      // run look at inventory interaction
      RunInventoryInteraction (game.inv_activated, MODE_LOOK);
   }

}


Make sure that the handle inventory clicks in script option is ticked (in order for inv clicks to take effect).

~Cheers

rtf

Wow, that's a lot of stuff.  Thank god for Copy-Paste! ;)

Thanks, scorpius!
I fail at art.

Dr Lecter

#3
I've done a 2.7 friendly version of this, although it is different because there is no support for inventory at all since the game I'm making as no active inventory, hence no using items on items. But if you want my code here it is:

Code: ags

function on_mouse_click(int button) {
// Makes note of which button was clicked
   if (IsGamePaused() == 1) {
   // Game is paused, so nothing happens
   }
   else if (mouse.IsButtonDown(eMouseRight)) {
      // If there is nothing to look at:
         if (IsInteractionAvailable(mouse.x,mouse.y, eModeLookat) == 0) {
  Display("Haven't you got better things to look at?"); // Insert your message here
   }
else  { // Since there is something to look at, look at it
ProcessClick (mouse.x, mouse.y, eModeLookat);
   }
   }
   else if (mouse.IsButtonDown(eMouseLeft)) {
      // If there is nothing to use, so walk
         if (IsInteractionAvailable(mouse.x,mouse.y, eModeInteract) == 0) {
ProcessClick (mouse.x, mouse.y, eModeWalkto);
   }
else { // Since there is something to use, use it
ProcessClick (mouse.x, mouse.y, eModeInteract);
       }
   }
}

If people want an inventory version I may be perswaded into adding it

SMF spam blocked by CleanTalk