Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: static on Thu 10/07/2003 11:09:23

Title: New function does not work
Post by: static on Thu 10/07/2003 11:09:23
I am trying to make a collision function. It should check the x coordinates of both objects/characters and then return a value if it's true.
But the problem is that I cannot make a new function. I even tried to
make simple ones like just displaying messages but they just do not work.

in global script:

function dice();{
Display ("It's a nice dice");
}

when character interacts with tree

dice();

I get this message:
Error(line 23): undefined token 'dice'

HELP
Title: Re:New function does not work
Post by: Barcik on Thu 10/07/2003 12:58:02
You have to add 'import dice();' in the script header.
Title: Re:New function does not work
Post by: Timosity on Thu 10/07/2003 13:24:17
also with this line:

function dice();{

you need to leave out the semi colon ie ";"

so the line looks like this:

function dice(){




so it works in all the scripts, do what Barcik says

but if you create a function in the global script, you can call it from the global script without importing it in the script header.

same in a room script
Title: Re:New function does not work
Post by: Scorpiorus on Thu 10/07/2003 15:03:25
...but don't forget this function word when importing.

Example:

global script:

function dice() {
 Display ("It's a nice dice");
}

script header:

import function dice();

-Cheers
Title: Re:New function does not work
Post by: Barcik on Thu 10/07/2003 16:00:09
right, sorry, my mistake