I'm making an AGS Plugin with Cplusplus. Everything seems ok until I put a line that goes like this.
int ics=AGSCharacter * GetCharacter(player).x;
and it goes with two errors :
A) GetCharacter is an undeclared identifier (but I've imported agsplugin.h)
B) left of '.x' must have class/struct/union type .
I've tried also with
int ics=GetCharacter(player).x; or something like that, and still nothing.
I would be very grateful if you answered soon, because I am in a deadline. No workarounds, if possible.Please.
Bye.
GetCharacter(player).x doesn't exist.
The reason to the first error is that the function, GetCharacter() simply doesn't exist.
The second you get because you're trying to access a member of class/struct/union where there cannot exist one, in a function. A function that did what you want would probably be something like this: GetCharacterX(player). But there is no function like that either.
What, however, probably would work is:
int ics=AGSCharacter * character[player].x;
Err... still no work.
I supposed that GetCharacter(player) existed. I copy and paste from the AGS Plugin API :
AGSCharacter * GetCharacter (int charid);
Returns the character state struct for character charid. This struct is documented in the header file, but is mostly identical to the character[] text script variable.
Beware when modifying character state structs. There are some caveats to watch out for, such as altering the X and Y values while the character is moving.
Also, remember that all view numbers stored are 1 less than the numbers shown in the editor and used in the text script.
Added in version: 6
So, I thought that this would return the character structure defined in agsplugin.h associated to the player corresponding to the value of the variable "player". It doesn't work. Damn.
CUG
It's either character[EGO] or just player. But I think the Plugin code and AGS code are different from each other.
--- EDIT ---
This is probably all quite wrong...
--- Original Message ---
Ah, ok. Then you'll have to use the class (or struct) meant for characters. It's probably called something like "char", so something like this:
char character1;
character1 = GetCharacter(player);
int ics = AGSCharacter * character1.x;
"char" is the name of the character structure, the docs should say what it should be called.
However, it's strange you get the first error if you've correctly included the plugin header file.
Ok, fixed the first part (point A). I had to do something like :
AGSCharacter *man = engine->GetCharacter(player);
But then I make something like :
int ics=man.x;
but it gives me the error "left of '.x' must have class/struct/union type". I thought that man referenced the structure AGSCharacter... what's wrong?
Hm, those pointers confused me a little... I'm not completely sure this'll work, but it's worth a try.
AGSCharacter *man = engine->GetCharacter(player);
this would create a pointer structure that points to player, right?
int ics = man.x;
as man is a pointer, not structure, this won't work, right? This, however, might just do the trick:
int ics = *man.x;
Good thought, but still it doesn't work. I hate computers.
Thank you anyway!
Having read through my docs on pointers, I think this'll work:
int ics = (*man).x;
or:
int ics = man->x;
which should do exactly the same thing.
Ouchy, I'm an idiot. And you are a genius. I was confused by the very evil Java.
Ludicrous thanks to you, Vargtass. I hope I can reciprocate (is "Reciprocate" a real word?) this sooner or later.