Using Object.GetAtScreenXY(x,y) as an object number (SOLVED)

Started by Coolio, Sun 15/10/2006 10:03:55

Previous topic - Next topic

Coolio

Sorry if the topic name is a bit hard to understand, but it was all I could think of to explain my problem.
Basically, I want to be able to name (or number) an object so that it is the same as the object returned by Object.GetAtScreenXY(x,y).
I have tried simply using
Code: ags
object[Object.GetAtScreenXY(x,y)]

But it says that there is a parse error after '['. Obviously you cannot convert the return of Object.GetAtScreenXY(x,y) to an integer.
I also tried using the return of Object.GetAtScreenXY(x,y) to evaluate a variable but obviously that didn't work either.
Can someone please help me. I have never done coding before so I don't really know what I'm doing but I hope that I have at least explained my problem adequately.
Thanks
mmmmm... sparkly

GarageGothic

#1
Maybe this can be written in a neater way,  but this is more or less the concept:

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


And then do whatever you need with myobjectnum. (of course you don't need the int at all, you can put myobject.ID directly into whatever function you're using the number in, but you need to check that the object isn't null first.)

Coolio

mmmmm... sparkly

SMF spam blocked by CleanTalk