Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: adam100 on Sat 03/01/2004 15:40:25

Title: On_event script
Post by: adam100 on Sat 03/01/2004 15:40:25
Hi.
I'm just learning to script in AGS and i wanted to put an on_event function in my game.So i put this in global script:

function on_event(int data , int event) {
if (event==GOT_SCORE) {
display("Wow,you just got some points");
}  
}
Then I put this in script header:

import function on_event(int , int);
And then i add this script to some action:
on_event(int data, int event).
And I get "parse error in exp near int".What am i doing wrong?
Title: Re:On_event script
Post by: Proskrito on Sat 03/01/2004 17:00:31
when you call a function, you must not write the parameter type (int / string... ) just the value.
Anyways, you shouldnt put the on_event function in the script header, nor calling it from a script, because it is manged internally by ags.
Just with this:
function on_event(int data , int event) {
if (event==GOT_SCORE) {
display("Wow,you just got some points");
}
}

Your game would display that message every time the player gets points, so no need to import / calling it. : )
Hope i'm right! : )
Title: Re:On_event script
Post by: Scorpiorus on Sat 03/01/2004 17:05:56
Just one more thing - the event must be the first parameter:

function on_event(int event , int data) {
if (event==GOT_SCORE) {
display("Wow,you just got some points");
}
}

~Cheers