Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: LeChuck on Sun 10/08/2008 03:13:32

Title: Forcing an unhandled event? (SOLVED)
Post by: LeChuck on Sun 10/08/2008 03:13:32
When combining an inventory item with an object or a hotspot, I sometimes miss the option to run the unhandled event script when trying to combine an item that's not connected to that object or hotspot. If I don't script anything at all under an objects / hotspots "Use Inventory on object" field, the unhandled event script will kick in. However, if I script one inventory item to trigger something using it on an object, how do I trigger the unhandled event script to take over for the rest of the items?


// script for Object 5: Use inventory on object
if (player.activeinv == 52) UseMagnet();
else unhandled_event(1,3); // this obviously doesn't work, hence this thread!



This secret knowledge I'm sure some of you hold would come in handy when the player is trying completely random stuff that suggests a specialized response. As opposed to objects like a locked door where you'd write something like "I can't unlock the door with this vacuum cleaner!" in the else field! :=
Title: Re: Forcing an unhandled event?
Post by: monkey0506 on Sun 10/08/2008 10:02:44
You could import the unhandled_event function I imagine, but I'm not 100% sure if that would work.

Otherwise, just script a custom function to do the same thing. You can even just make the custom function call unhandled_event function.

Edit: My only concern was that since unhandled_event is one of the managed event handler functions, AGS might not like you throwing it around the scripts. I don't know that it would actually cause problems or not, hence "not 100%". ;)
Title: Re: Forcing an unhandled event?
Post by: Khris on Sun 10/08/2008 10:51:16
Yes, it will work.
Just add this to the header:
import function unhandled_event(int what, int type);
Title: Re: Forcing an unhandled event?
Post by: LeChuck on Sun 10/08/2008 14:25:34
Quote from: KhrisMUC on Sun 10/08/2008 10:51:16
Yes, it will work.
Just add this to the header:
import function unhandled_event(int what, int type);

Ouch! Now why didn't I try that? :-\

Thanks!