Function problems eg FaceDirection

Started by subspark, Tue 02/09/2003 11:23:40

Previous topic - Next topic

subspark

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?

SSH

12

subspark

#2
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?

SSH

I mean you need to call the function with:
FaceDirection (EGO, "left");

for example
12

subspark

tried that ages ago

gives an error too

SSH

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);
12

subspark

oops again i forgot the (int, string);

;D

SSH

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.
12

Pumaman

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 ;)

SMF spam blocked by CleanTalk