have mercy

Non-platform specific questions.

have mercy

Postby Agusstosus15 » Sun Oct 16, 2011 6:21 pm

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....
Agusstosus15
 
Posts: 59
Joined: Sun Oct 09, 2011 7:59 pm
Score: 0 Give a positive score

Re: have mercy

Postby EvanBlack » Sun Oct 16, 2011 7:25 pm

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;

(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: have mercy

Postby Agusstosus15 » Sun Oct 16, 2011 7:46 pm

ok , thanks a lot and another question , is there a way to tread clone index like variable inside this code?
Agusstosus15
 
Posts: 59
Joined: Sun Oct 09, 2011 7:59 pm
Score: 0 Give a positive score

Re: have mercy

Postby skydereign » Sun Oct 16, 2011 8:57 pm

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);
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: have mercy

Postby Agusstosus15 » Sun Oct 16, 2011 9:53 pm

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?
Agusstosus15
 
Posts: 59
Joined: Sun Oct 09, 2011 7:59 pm
Score: 0 Give a positive score

Re: have mercy

Postby skydereign » Sun Oct 16, 2011 9:57 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: have mercy

Postby Agusstosus15 » Sun Oct 16, 2011 10:03 pm

myarray[0]= getclone(buffer)->x;

Have i get x position of myactor?
Agusstosus15
 
Posts: 59
Joined: Sun Oct 09, 2011 7:59 pm
Score: 0 Give a positive score

Re: have mercy

Postby skydereign » Sun Oct 16, 2011 10:07 pm

Yeah. I only put in the ActorArray since EvanBlack put it in, but that'll work too.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: have mercy

Postby EvanBlack » Sun Oct 16, 2011 10:14 pm

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.htm

Example:

buffer == "myActor.0"

myarray[0] = getclone(buffer)->x;

myarray[0] == myActor.x
Last edited by EvanBlack on Sun Oct 16, 2011 10:17 pm, edited 1 time in total.
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: have mercy

Postby Agusstosus15 » Sun Oct 16, 2011 10:17 pm

fantastic that's the half of my problem
you helped me a lot ,big thanx :) you're good man
Agusstosus15
 
Posts: 59
Joined: Sun Oct 09, 2011 7:59 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest