Ok, here's the problem:
I would like to use a global function when an event occours but the compiler says he can't find the function.
I wrote a "cantTalkToIt()" function in the global script and then I imported it in the global script header. In the event editor of each object i wrote "cantTalkToIt" in the "Talk to object" field but it doesn't work.
I really don't want to write the same function for every object in every room...
You don't even have to put the function's name into every object's TalkTo event field.
In the global script, find on_mouse_click and in there the eMouseLeft block.
Now put this at the start:
if (mouse.Mode == eModeTalkto && GetLocationType(mouse.x, mouse.y) == eLocationObject) {
cantTalkToIt();
return;
}
I'm not sure exactly what the problem is with your method; I'd be surprised if one can't link global functions to room events but maybe that's the case.
It's a good solution if I would call the function for every object.... but this function will be called for just about half of the objects :-\
Then just do what you're supposed to be doing anyway; add this to the global script:
function unhandled_event (int what, int type) {
if (what == 2) { // object
if (type == 2) { // talk to object
// code goes here
}
...
}
...
}
Now if the player tries to talk to an object and the respective event field is empty, the unhandled_event function takes over.
For the full documentation, look at the bottom of this manual page: http://www.adventuregamestudio.co.uk/manual/TextScriptEvents.htm
Uuuh...cool! I can use this also for the "ItDoesntWork()" function ^_^
Thank you, I didn't know of a funcion for unhandled events. :)