C++ Question for AGS Plugin

Started by CUG, Mon 28/07/2003 13:20:45

Previous topic - Next topic

CUG

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.


MachineElf

#1
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;
There are 10 kinds of people in the world: Those who understand binary and those who don't.

CUG

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

TerranRich

It's either character[EGO] or just player. But I think the Plugin code and AGS code are different from each other.
Status: Trying to come up with some ideas...

MachineElf

#4
--- 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.
There are 10 kinds of people in the world: Those who understand binary and those who don't.

CUG

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?

MachineElf

#6
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;
There are 10 kinds of people in the world: Those who understand binary and those who don't.

CUG

Good thought, but still it doesn't work. I hate computers.

Thank you anyway!

MachineElf

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.
There are 10 kinds of people in the world: Those who understand binary and those who don't.

CUG

#9
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.

SMF spam blocked by CleanTalk