Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: san.daniele on Thu 23/05/2013 13:32:16

Title: define interactions globally
Post by: san.daniele on Thu 23/05/2013 13:32:16
I probably used wrong wording in the title, but here's what I'm looking for:

there are several things in my game that apply to every hotspot/object (actually, I guess that's the case in almost every game).

like using whatever inventory item on whatever object/hotspot.
I defined lots of them, but I wonder if there's a way to add something to the GlobalScript, that comes into action if I didn't specify anything else in the room script? the character would just say something like "nope" or "can't use that here".
(hope I made myself clear)

similar to the above: is there a way to make ALL objects unclickable? (I'm sure there is and it's a veeery basic thing to know. so the question should be: what's the code for it?) I only use hotspots for interactions and it's a little annoying to manually make each object unclickable.
Title: Re: define interactions globally
Post by: Khris on Thu 23/05/2013 13:42:30
There's a built-in function called unhandled_event (http://www.adventuregamestudio.co.uk/manual/index.html?page=ags42.htm#textscriptevents) for this (bottom of the page).

You can also create completely custom global controls by using Game.GetLocationType, the various .GetAtScreenXY functions, and rewriting on_mouse_click.

Making all objects unclickable:
Code (ags) Select
function on_event(EventType event, int data) {
  if (event == eEventBeforeFadein) {
    int i;
    while (i < Room.ObjectCount) {
      object[i].Clickable = false;
      i++;
    }
  }
}
Title: Re: define interactions globally
Post by: san.daniele on Thu 23/05/2013 13:47:59
As so many times before: Khris saves the day.

Thanks a lot!