ID number with GetAtScreenXY (SOLVED)

Started by Valentine, Tue 10/06/2008 21:01:53

Previous topic - Next topic

Valentine

I was wondering if there's any way to return a character ID number with Character.GetAtScreenXY rather than getting the character name? The only was I can think of doing it is something along the lines of 'if (Character.GetAtScreenXY==cEgo) { CharacterID=1; }' but that doesn't seem a very efficient way (at all) of doing it.

Searching the boards I found this piece of code:

int myobjectnum;
Object *myobject = Object.GetAtScreenXY(x, y);
if (myobject != null) myobjectnum = myobject.ID;

which I think might be useful to what I need to do (?), but I'm not sure how to use it in my script.

Thanks for any help!

skuttleman

Code: ags

int characterid;
Character* mycharacter = Character.GetAtScreenXY(mouse.x, mouse.y);
if (mycharacter != null) characterid = mycharacter.ID;
else characterid = -1;

if (characterid > -1) character[characterid].Say("Get your mouse cursor off me, you damned dirty ape!");


Is that what you wanted?

Valentine

Ah thanks for that, just what I needed. I guess I should have done some more experimenting with the code I found.

Now I just need to deal with all my characters realising it was Earth all along...

skuttleman

Quote from: Valentine on Tue 10/06/2008 21:27:12
Now I just need to deal with all my characters realising it was Earth all along...

HAHAHAHA! Well played.

SMF spam blocked by CleanTalk