On_event script

Started by adam100, Sat 03/01/2004 15:40:25

Previous topic - Next topic

adam100

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?

Proskrito

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:
Code: ags
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! : )

Scorpiorus

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

SMF spam blocked by CleanTalk