SUGGESTION: Revisions for unhandled_event & LocationType

Started by monkey0506, Thu 14/09/2006 19:04:08

Previous topic - Next topic

monkey0506

I've been looking at unhandled_event, and I think it could use some reworking. Basically, I think it would work best if unhandled_event was defined like this:

Code: ags
function unhandled_event(LocationType type, CursorMode mode)


That way the user could use any cursor mode for any unhandled interaction (presumably it would never be called for modes such as eModePointer and eModeWait, but it would be called for Cursor mode 8, 9, 10, etc.). Of course this brings up the point that nothing and inventory items would be indiscernible from each other...which is why I'd also like to suggest that a value (eLocationInventory(Item)) be added to the LocationType enumeration. Game.GetLocationName returns the name of InventoryItems, so I think it would be reasonable for GetLocationType to discern between nothing and InventoryItems.

Thanks.

Ashen

Isn't it fairly easy to work around the unhandled_event issue, though? You can alter the function declaration to use your own enum for the 'what' parameter, and ignore the 'type' parameter in favour of mouse.Mode or game.used_mode, e.g. (briefly tested):
Code: ags

// in Global Header
enum UnhandledTWhat {
  eUnhandledHotspot = 1,
  eUnhandledObject,
  eUnhandledCharacter,
  eUnhandledNothing,
  eUnhandledInventoryItem
};

// in Global Script
function unhandled_event(UnhandledWhat what, int type) {
  if (what == eUnhandledCharacter) {
    if (game.used_mode == eModeInteract) player.Say("I don't think they'd like that.");
    else if (game.used_mode == eModeLookat) player.Say("They're nothing special.");
    // Etc.
  }
  else if (what == eUnhandledObject) {
    // Whatever
  }
  // Etc.
}


Of course, if it could be made to support all cursor modes - and in a consistant manner (currently, type == 1 is 'Look at' for Hotspots and nothing, but 'Interact with' for Characters, Objects, and Items) - by default, that would obviously be better.
I would like to see the eLocationInventory value added, and eLocationGUI as well. Having them lumped together with eLocationNothing never really made sense to me.
I know what you're thinking ... Don't think that.

monkey0506

#2
Actually I'm not even using unhandled_event right now because it doesn't seem to be called from a module script?

Instead I've created a custom InteractionAvailable function which checks for interactions via IsInteractionAvailable AND InventoryItem.IsInteractionAvailable, and then calls a custom unhandled event handler (lol) (this is part of my MI template).

Furthermore, the real reason I was requesting this is so that more cursor modes would be handled (idealistically...all of them (all the user-defined cursors)). Not just to have the first parameter enumerated.

And GUIs registering as nothing is okay for me because they don't have names returned by Game.GetLocationName...however I'm not against the idea of having an eLocationGUI.

[EDIT:]

And you know...thinking about it...InventoryItems and GUIs may have been lumped together with "nothing" due to the fact that they are all treated the same by certain functions (namely, ProcessClick). ProcessClick ignores InventoryItems and GUIs...so...maybe it comes from that? (In any case (regardless of the logic behind it) I'd still like to see some changes ;))

Pumaman

Yes, unhandled_event is ugly and could do with some rework, it's something I'd like to do at some stage.

SilverWizard_OTF

However even if it remains as it is, it's still very useful function. Recently i noticed that the idea of displaying a message wherever player would click, it's marvellous, and helps to prevent player from easily discovering what's a hotspot and what it is not.
"All we have to decide is what to do, with the time that is given to us"

SMF spam blocked by CleanTalk