Can you turn off an interaction (eg. talkto) with one command?

Started by bx83, Mon 25/03/2019 08:35:20

Previous topic - Next topic

bx83

You can *check* if an interaction is available:
Code: ags
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?

Khris

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.

Crimson Wizard

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: ags

bool AllowRunInteraction(Character *c, CursorMode mode)
{
    if (mode == eModeTalkto && c.GetProperty("CanTalkTo") != 0) return true;
    if (mode == eModeLook && c.GetProperty("CanLookAt") != 0) return true;
    return false;
}

Code: ags

function on_mouse_click(...)
{
....
   if (btn == eMouseLeft)
   {
       .... 
       Character *ch = Character.GetAtScreenXY(mouse.x, mouse.y);
       if (AllowRunInteraction(ch, mouse.Mode))
          ch.RunInteraction(mouse.Mode);
   }
....
}

bx83


SMF spam blocked by CleanTalk