Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: subspark on Tue 02/09/2003 11:23:40

Title: Function problems eg FaceDirection
Post by: subspark on Tue 02/09/2003 11:23:40
Ive implemented the following code into my Global Script:

function FaceDirection(int charid, string direction) {
 // script for ego to face a direction
if (StrComp(direction,"down")) {
FaceLocation(charid,character[charid].x,character[charid].y+10);
}
if (StrComp(direction,"front")) {
FaceLocation(charid,character[charid].x,character[charid].y-10);
}
if (StrComp(direction,"left")) {
FaceLocation(charid,character[charid].x+10,character[charid].y);
}
if (StrComp(direction,"right")) {
FaceLocation(charid,character[charid].x-10,character[charid].y);
}
}

but when i call FaceDirection (EGO, left);

i get a compile error such as undefined symbol "left"

any ideas?
Title: Re:Function problems eg FaceDirection
Post by: SSH on Tue 02/09/2003 11:45:14
Quotes
Title: Re:Function problems eg FaceDirection
Post by: subspark on Tue 02/09/2003 12:12:22
what u mean """?;)

nah thats not the problem its supposed to be like that.

the function properties display it as "left" and you call FaceDirection left without quotation marks. The whole point is to make this all easier.

i tried adding quotation marks in suspicious places removing them what exactly do you mean Quotes?
Title: Re:Function problems eg FaceDirection
Post by: SSH on Tue 02/09/2003 12:13:48
I mean you need to call the function with:
FaceDirection (EGO, "left");

for example
Title: Re:Function problems eg FaceDirection
Post by: subspark on Tue 02/09/2003 12:15:49
tried that ages ago

gives an error too
Title: Re:Function problems eg FaceDirection
Post by: SSH on Tue 02/09/2003 12:24:50
What error?
How is your script header set up? I've jst tried your code, calling with "left", not left and it works fiune for me. My script header has:

import function FaceDirection(int, string);
Title: Re:Function problems eg FaceDirection
Post by: subspark on Tue 02/09/2003 12:28:21
oops again i forgot the (int, string);

;D
Title: Re:Function problems eg FaceDirection
Post by: SSH on Tue 02/09/2003 12:30:45
Actually, I think this is a common thing to forget and it would be nice if CJ could produce a better error message when your import doesn't match the global function definition...

I knwo becuase I did the same as subspark did first time, then I checked the manual and fixed it.
Title: Re:Function problems eg FaceDirection
Post by: Pumaman on Tue 02/09/2003 19:16:39
Aye, that's been on my list for a while, but it's a bit fiddly to implement so I keep putting it off.

I'll get round to it at some stage though, promise ;)