Just a query with unhandled event function

Started by Timosity, Fri 31/10/2003 08:34:15

Previous topic - Next topic

Timosity

I've just set up an unhandled event function and I'm not sure if this is a bug, (I can see why it might happen) but when using an inventory item on another,

If the item being clicked on with another item, already has a function, other items clicked on it (that are unhandled) aren't considered unhandled events.

Eg. (a piece of wood is the inventory being interacted with) Use a knife on the piece of wood to cut it, and I add the necessary action to cut it.

Now if I've used an unhandled event function, every time I use anything else on it, I have to add a separate interaction with that item, If I don't there is no message.

It just seems odd that an item I haven't associated an action with isn't considered unhandled.

I guess it's just when you associate one action with an inventory item, every other action with any other item on it, has to now be handled. (i guess it uses the same variable for each object)

Is this the case or is there another way, or has no one thought about it?

a-v-o

You can try something like this way:
For all usable items you create these conditional branches in the interaction editor with "stop running more commands" at their end. After all this you add a "run script" action and call the function unhandled_event with the correct parameters.

ThunderStorm

I've had a similar problem in my game, and I solved it by calling unhandled_event manually. So I put the line
#import unhandled_event(int,int)
in the script header. In the interaction script of the object, I did something like

if (active inventory object is knife){ do the interaction }
else { unhandled_event(x,y) }


I don't have the exact script here, but it worked for me that way.

Hope  this helps.

Timosity

Thanks for the ideas, a-v-o and Thunderstorm,

I only have one Item in my game that is interacted with another item, so it wasn't too much hassel to do the interactions (although there's about 30 other items, but only about 6 of them are in possession when I have the other item)

But yes, I can see how that should work.

it actually happens with characters aswell if you assign an inventory interaction with them, probably objects too, so I figure if you assign 1 inventory interaction it counts for all items. But I usually add specific handled events for these.

Thanks for the replies

~Tim

Pumaman

Basically, if in response to a "Use inventory" event, you just have a "Run script", then AGS has no way of knowing what your script is checking for, and therefore will not call unhandled_event - your script will have to do it manually, as ThunderStorm suggests.

If you are just using the interaction editor with conditionals "if inventory item X was used" then it should run unhandled_event if they choose a different one.

Timosity

#5
Yeah, it's interesting, I started off using the interaction editor, until I became more confident with scripting, then started using

eg.

// script for character20: Use inventory on character
if (character[GetPlayerCharacter()].activeinv==14) {
Display("'No, I'm not going to be your date for the prom!'");
}

if (character[GetPlayerCharacter()].activeinv==30) {
Display("'Isn't that precious? he snarls. 'A hunk of wood. Indeed!'");
}

but if I say, did this, would it work, (I don't care too much about an answer cause I will try it myself later when I get the chance)

// script for character20: Use inventory on character
if (character[GetPlayerCharacter()].activeinv==14) {
Display("'No, I'm not going to be your date for the prom!'");
}

else if (character[GetPlayerCharacter()].activeinv==30) {
Display("'Isn't that precious? he snarls. 'A hunk of wood. Indeed!'");
}

else {
unhandled_event (); // characters are in global script so I see no reason why this shouldn't work
}

also I can see why you would use #import unhandled_event(int,int) so you can use it throughout the room scripts with objects/hotspots etc

SMF spam blocked by CleanTalk