Page 1 of 1
have mercy
Posted:
Sun Oct 16, 2011 6:21 pm
by Agusstosus15
strcpy(nazwy[3],"pozycja_las_1");
tym[0]=nazwy[3].x;
tym[1]=nazwy[3].y;
why i can't get x,y coordinates of "pozycja las" actor?
the error is- illegal structure....
Re: have mercy
Posted:
Sun Oct 16, 2011 7:25 pm
by EvanBlack
Thats not how it works...
you need to make an Actor* array to access the x,y
- Code: Select all
Actor* ActorArray[10];
int XYArray[2];
ActorArray[0] = getclone("myActor");
XYArray[0] = ActorArray[0]->x;
XYArray[1] = ActorArray[0]->y;
With your code you would have to do this:
- Code: Select all
strcpy(nazwy[3],"pozycja_las_1.0"); // .0 is the clone index.
tym[0]=getclone(nazwy[3])->x;
tym[1]=getclone(nazwy[3])->y;
Re: have mercy
Posted:
Sun Oct 16, 2011 7:46 pm
by Agusstosus15
ok , thanks a lot and another question , is there a way to tread clone index like variable inside this code?
Re: have mercy
Posted:
Sun Oct 16, 2011 8:57 pm
by skydereign
By using sprintf on a string, you can insert any cloneindex you want. In this case I made a variable desired_cloneindex and used that, but you can replace that with anything.
- Code: Select all
int desired_cloneindex = 5;
char buffer[50];
Actor* ActorArray[10];
sprintf(buffer, "myActor.%d", desired_cloneindex);
ActorArray[0] = getclone(buffer);
Re: have mercy
Posted:
Sun Oct 16, 2011 9:53 pm
by Agusstosus15
so, correct me if I'm wrong-
value of variable desired cloneindex is writing in d
myActor name with cloneindex of course is writing in buffer
actorarray is getting information about cloneindex wrote in buffer?
and if so than can I get information about clonename wrote in buffer?
Re: have mercy
Posted:
Sun Oct 16, 2011 9:57 pm
by skydereign
Okay, the clonename of the actor is stored in buffer. The actual index used in the clonename is got from the desired_cloneindex variable (because of the %d in sprintf). You then use getclone to retrieve the Actor* of that actor, and store it into the ActorArray. That way you can access the ActorArray[0] to change values of that clone.
Re: have mercy
Posted:
Sun Oct 16, 2011 10:03 pm
by Agusstosus15
myarray[0]= getclone(buffer)->x;
Have i get x position of myactor?
Re: have mercy
Posted:
Sun Oct 16, 2011 10:07 pm
by skydereign
Yeah. I only put in the ActorArray since EvanBlack put it in, but that'll work too.
Re: have mercy
Posted:
Sun Oct 16, 2011 10:14 pm
by EvanBlack
That would work as long as buffer a string that is the name of your actor clone. Yeah, the array can be named anything you want. Don't think that just because its was named a certain way by another person means you have to name it that way.
You should probably read more about using
c programming and use this documentation more to:
http://game-editor.com/docs/script_reference.htmExample:
buffer == "myActor.0"
myarray[0] = getclone(buffer)->x;
myarray[0] == myActor.x
Re: have mercy
Posted:
Sun Oct 16, 2011 10:17 pm
by Agusstosus15
fantastic that's the half of my problem
you helped me a lot ,big thanx
you're good man