BUG - Unhandled event

Started by Rui 'Trovatore' Pires, Tue 13/04/2004 20:16:48

Previous topic - Next topic

Rui 'Trovatore' Pires

I used the following line of code in unhandled event -

 if ((what==1 && type==8) || (what==2 && type==6) || (what==3 && type==6)) {

Now, theoretically the next commands should be called by using Mode 8 on a hotspot, or an object, or a character, right?

...Then, WHY does it actually check for ANY CLICK instead of MODE 8? And I tested this - removing all interactions in ANY CLICK made it work, and it didn't before.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Scorpiorus

Being defined "Any click" runs regardless what cursor mode is used and, as the manual states, it (as well as "character stands on hotspot") doesn't trigger the unhandled_event() function in that case.

Rui 'Trovatore' Pires

But it IS being triggered by unhandled_event!

So - my cursor 8 is mode Talk. Let's say I have a function, called "Random Message", which is run in unhandled_event, so I don't have to define a "talk" interaction for every single thing.

So, my unhandled_event looks like -

if ((what==1 && type==8) || (what==2 && type==6) || (what==3 && type==6)) RandomMessage();

But when I try it out, it doesn't work. I bump my head a few times, and then, seeing as it worked on the OTHER hotspots, which didn't have ANY interaction defined, I eliminated, one by one, all the interactions I had made for my hotspot. And it worked when I deleted the interactions in Any Click. And when I put interactions there again, it didn't work again.

Any Click IS actually being called. Fun. But seeing as I want this to happen to Cursor Mode 8 and not Any Click... BUG!
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SSH

Actually, that "all Any Click events do not trigger this function" bit in the manual is a bit unclear as to what it means. However, it seems "natural" to me that if you have an interaction that is triggered on any click then any click will go to that interaction and not to unhandled_event. I mean why not just put an "else" in your Any Click code to call RandomMessage?

In fact, it seems that the help file isn't entirely clear as to whether "Any Click" means any click or any other click (ie not one of the otehr interactions). It says that for hotspots it means any click: so" look" will trigger both "look" and "any click" interactions, but for characters and inventory is seems to mean "other" clicks, not inlcuding the otehr interactions. Inconsistent, at least...!
12

Rui 'Trovatore' Pires

But SSH, RandomMessage ISN'T called from Any Click. It's called from Use Mode 8, the penultimate interaction in the editor. The point is, THAT'S the interaction that unhandled_event should check for with the parameters I specified, but instead it's checking Any Click.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SSH

Hang on, I thought you were saying that the Bug was that if you had an Any Click interactiuon on your hotspot then that got called instead of unhandled_event when you clicked with cursor mode 8.

But now you seem to be saying that unhandled_event is being called when you click with any click on the hotspot, if you have an any click interaction...

Can you explain exactly what does and doesn't happen when, again, please?
12

Rui 'Trovatore' Pires

#6
<laugh> I'm probably making a big mess. I gues I'll have to show you. I can't explain it myself.

Make a hostpot. Then add the line I talked about earlier, plus some command, after unhandled_event. Like,

function unhandled_event (int what, int type) {
if ((what==1 && type==8) || (what==2 && type==6) || (what==3 && type==6)) Display("Hello, world.");
}

Then try your hotspot out. As it has no interactions, the message is displayed. But now, try putting an interaction in your ANy Click interaction, and re-check the manual's description of the WHAT and TYPE values. Do you see?

EDIT - Putting any interaction in ANY CLICK shouldn't affect the unhandled_event thingy, because it never remotely checks for it. But it does.

EDIT 2 - I forgot  - when trying it out, be sure to use MODE 8, of course.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SSH

But since ALL clicks on a hotspot trigger the Any Click interaction, the unhandled_event function shouldn't be called, as the click is now handled (by the Any Click interaction).
12

SSH

Quote from: redruM on Wed 14/04/2004 14:19:18
EDIT - Putting any interaction in ANY CLICK shouldn't affect the unhandled_event thingy, because it never remotely checks for it. But it does.

I think it is this assumption that you have made that is wrong... where do you get this from?
12

Rui 'Trovatore' Pires

Oh! Is THAT what the manual means???? I never realized it yet!!!

But... that doesn't make much sense. I've got 12 cursor modes, and the only way to acess them is using Any Click! How am I going to use unhadled_event?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SSH

At the end of every any_click script, put:

else {
RandomMessage();
}

or something like that. The joy of cut-and-paste...

or maybe, you could actually only really use cursor modes 8 and 9 and use a global variable to keep track of whether you are REALLY in mode 9 or if you are in modes 10-12 instead?
12

Rui 'Trovatore' Pires

#11
<sigh> I'll go with the first. But, while I do understand it now, and I agree it does make sense... it's impractical. I wonder if CJ can make this behaviour "toggleable", or even if he'll find it worth it...

...anyway, I guess I'd better request it oficially.

<ahem> I'd like to request the "toggleability" of having Any Click not calling unhandled_event, for reasons already specified.

(and, thanks a lot, SSH)

EDIT - Or maybe I'll play a bit with ProcessClick. It might help.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Scorpiorus

#12
Yeah, the any click overrides the unhandled_event().

QuoteIn fact, it seems that the help file isn't entirely clear as to whether "Any Click" means any click or any other click (ie not one of the otehr interactions). It says that for hotspots it means any click: so" look" will trigger both "look" and "any click" interactions, but for characters and inventory is seems to mean "other" clicks, not inlcuding the otehr interactions. Inconsistent, at least...!
Anyway, afaik, it works the way that if both interaction event and any click event have scripts (actions) attached AGS runs them both (don't remember what first though).

[EDIT]

Quote from: redruM on Wed 14/04/2004 14:36:57But, while I do understand it now, and I agree it does make sense... it's impractical.
On the other hand it seems reasonable:

You click with a mouse and...
AGS checks if the specified interaction has a script (actions) to run. (i.e. defined)
Then AGS checks if anyclick interaction has a script to run.
Finally, if the interaction isn't defined and anyclick is empty AGS runs the *default* unhandled_event() to handle the event.

SSH

A more general mechanism might be if there was a switch to disable all automatic handling of events and require that scripts  call a HandleEvent(); function (similar to ClaimEvent's operation). It would mean that the IsInteractionAvailable function would have to dummy-run through an interaction and see if HandleEvent would be called...

12

Pumaman

redruM: the problem with your request is that you'd end up with unhandled_event always getting run on every click.

Something like SSH's suggestion would probably be the cleanest solution to this, however it's almost as easy to simply put:

else {
 unhandled_event(1, 8);
}

or whatever at the end of your interaction script.

Rui 'Trovatore' Pires

Kay, I see. Oh well, in this particular case fiddling with on_mouse_click and properties did the trick. Ah, the joys of working around problems...
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SMF spam blocked by CleanTalk