Author Topic: Can you turn off an interaction (eg. talkto) with one command?  (Read 232 times)


  • Get 'Er Doooooone
You can *check* if an interaction is available:
Code: Adventure Game Studio
  1. IsInteractionAvailable(eModeTalkto)

I was wondering if you can turn off interactions that are already?
You have an interaction for a character (cCharater_Talk() has been set and filled in with some code); how do you turn this off/on at will?
Or do you have to set a custom property and use this to turn it on or off through various mouse cursor trickery?


  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
The short answer is to use a global variable, afaik AGS doesn't have a shortcut to turn off interactions.

There's also Game.DoOnceOnly(), although you'd have to manually call unhandled_event in the else block.

I may suggest using Custom Properties to flag enabled/disabled interactions (you may now change their values at runtime too) because they are already bound to an object.

For a quick example:
Code: Adventure Game Studio
  1. bool AllowRunInteraction(Character *c, CursorMode mode)
  2. {
  3.     if (mode == eModeTalkto && c.GetProperty("CanTalkTo") != 0) return true;
  4.     if (mode == eModeLook && c.GetProperty("CanLookAt") != 0) return true;
  5.     return false;
  6. }
Code: Adventure Game Studio
  1. function on_mouse_click(...)
  2. {
  3. ....
  4.    if (btn == eMouseLeft)
  5.    {
  6.        ....
  7.        Character *ch = Character.GetAtScreenXY(mouse.x, mouse.y);
  8.        if (AllowRunInteraction(ch, mouse.Mode))
  9.           ch.RunInteraction(mouse.Mode);
  10.    }
  11. ....
  12. }
« Last Edit: 25 Mar 2019, 12:12 by Crimson Wizard »


  • Get 'Er Doooooone
As I thought - I've created a custom property.
Thanks :)