function unhandled_event

Started by demophobie, Sat 06/10/2007 11:37:04

Previous topic - Next topic

demophobie

Hi !

I could not find a workaround for following problem:
Here a part of my code:

function unhandled_event (int what, int type)
{
 
  if (what == 1)
    {
    if (type == 1) Display("Ich sehe nichts Besonderes.");
    else if (type == 2) Display("Das kann ich nicht benutzen.");
    else if (type == 3) Display("Das funktioniert so nicht.");
    else if (type == 4) Display("Es antwortet nicht.");
    else if (type == 7) Display("Ich kann das nicht nehmen.");
    else if (type == 8) Display("Ich kann das nicht bewegen.");
    else if (type == 9) Display("Das kann ich nicht oeffnen.");
    }
}

Now i want to add a message like this for my cursor 10.
But the manual says:

WHAT TYPE Description
1    1   Look at hotspot
1    2   Interact with hotspot
1    3   Use inventory on hotspot
1    4   Talk to hotspot
1    7   Pick up hotspot
1    8   Cursor Mode 8 on hotspot
1    9   Cursor Mode 9 on hotspot

a "Cursor Mode 10 on hotspot" cant be supported?
i tried if type = 10, but that didnt work.
Does anyone have an idea!?

thanks for the help!

Patrick

Rui 'Trovatore' Pires

Do something like

function unhandled_event (int what, int type)
{
 
  if (what == 1)  {
    if (mouse.Mode==*yourmode10here*) Display ("Das kann nicht sein.");
    else {
    if (type == 1) Display("Ich sehe nichts Besonderes.");
    else if (type == 2) Display("Das kann ich nicht benutzen.");
    else if (type == 3) Display("Das funktioniert so nicht.");
    else if (type == 4) Display("Es antwortet nicht.");
    else if (type == 7) Display("Ich kann das nicht nehmen.");
    else if (type ==  Display("Ich kann das nicht bewegen.");
    else if (type == 9) Display("Das kann ich nicht oeffnen.");
    }
}
}
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

demophobie

oh okay, a simple if/else works here?

i thought this function_unhandled only accepts this what/type stuff.

i like ags more and more :)
thank u

demophobie

Hm...
It doesn't work in my code.

My GUI does:

if (button == 5) {       // Schliesse
  mouse.Mode = 10;
}

And my code is now:

function unhandled_event (int what, int type)
{
    if (what == 1)
    {
    if (mouse.Mode==10) Display("Das kann ich nicht schliessen.");
    else {
             if (type == 1) Display("Ich sehe nichts Besonderes.");
             else if (type == 2) Display("Das kann ich nicht benutzen.");
             else if (type == 3) Display("Das funktioniert so nicht.");
             else if (type == 4) Display("Es antwortet nicht.");
             else if (type == 7) Display("Ich kann das nicht nehmen.");
             else if (type == 8) Display("Ich kann das nicht bewegen.");
             else if (type == 9) Display("Das kann ich nicht öffnen.");
         }
    }
}

any idea?

Gilbert

Hmmm, I think that won't work this way, it seems unhandled_event() would only be executed if the mouse modes are the only as mentioned in the manual (up to 9), so custom mode 10 may not cause this function to be executed.

There're several possible solutions I think, say, one is to try not to use mode 10, but swap mode 10 with another mode which is possibly less useful; another is to use on_mouse_click() and check for different details for it to work, etc.

Rui 'Trovatore' Pires

Well, I'll be. Yeah, u.e.'s probably not even getting called.

on_mouse_click is indeed a good place for it. Do something like

if (mouse.Mode==10) {
   Hotspot *temphot=Hotspot.GetAtScreen(mouse.x,mouse.y);
   if (temphot!=null) {
     if (!temphot.IsInteractionAvailable(whateverinteraction)) Display ("Whatever");
}
}

BTW, couple of things... I wish I could have done

if (mouse.Mode==10 && !Hotspot.GetAtScreen(mouse.x,mouse.y).IsInteractionAvailable(whatevermode) {

...but it don't work with GetAtScreen, this sort of thing. How come? Also, I wish I could have done...

if (temphot!=null && (!temphot.IsInteractionAvailable(whateverinteraction))

...instead of splitting it two ways, but if I did that and temphot came off null it'd error out when trying to see if the interaction was available.

CJ, are these things we'll just have to endure? Or are you considering changing them? What is the reason for them being like this?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Ashen

What about calling unhandled_event manually from the 'Any click on (Hotspot/Charcter/Object/Item)' interaction? That way, you'll know it's called, whatever the mode is. You already need to use 'Any click' to run mode 10 interactions, and if there's somthing under that, u_e won't run whatever the current mode. So if you'd need to call u_e yourself for anything with a mode 10 interaction, why not call it for everthing?

You can even pass mouse.Mode for type  (e.g. unhandled_event(1, mouse.Mode)) and make the code a little easier to read, as it'll use mode names instead of arbitary numbers. This means the type values listed in the manual might not work - (2, 1) would be 'Look at Object', not 'Interact with Object', etc - but I think it makes more sense this way, anyway.
I know what you're thinking ... Don't think that.

demophobie

Thanks!

I used Ashen's method.

I dont want to open a new topic for that:

I have a gui button named "Gib" = "give".
If i have an inventory item and try to give it to someone, i still can give it to the item itsself.
for example: "Give hammer to hammer".
I tried to it with "if.... && GetLocationType(mousex,mousey) != eLocationNothing" but that includes the gui too, which destroy my code (see manual : eLocationNothing = nothing, GUI or inventory).

Any idea how to solve that? Is there a command which can give me out, if i'm on an inv. item or not?


Ashen

Check the manual, you're after InventoryItem.GetAtScreenXY - just pass mouse.x, mouse.y as the coords, and it'll be null if the mouse isn't over an Item. There's no direct GetAtMouse function, but that'd be easy enough to code yourself (especially with the extender functions in the 3.0 betas).
I know what you're thinking ... Don't think that.

demophobie

ah, great! thx
still hanging with this NoBlock stuff *grml*

SMF spam blocked by CleanTalk