clone index question

You must understand the Game Editor concepts, before post here.

clone index question

Postby savvy » Sat Apr 16, 2011 12:55 pm

ok, so im trying to make it so that the view moves to a specific actor depending on its clone index. (short level transfer thing)
i have this so far, according to GE documentation...
Code: Select all
int i = level; //level is the level variable
Actor*getclone(char*levelindicator);
x=levelindicator[i].x;

im trying different things... if i get it right ill post so here, and show what i put.

please help

savvy
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: clone index question

Postby DarkParadox » Sat Apr 16, 2011 5:15 pm

Well, as it's my habit, I always use cloneID [by Feral] when working with clones (put in global code, save it):
Code: Select all
char buffer[50];
char * cloneID(const char *cname, short unsigned int cindex)
{
    sprintf(buffer, "%s.%d", cname, cindex);
    return buffer;
}


And use this code:
Code: Select all
// We don't need "i" anymore, just use level directly
x=getclone(cloneID("levelindicator", level))->x;
// See here, get clone lets us get a variable from a clone, and cloneID sets the name for us.
// The "->" is required instead of a "." when using getclone, and the X is retrieved.


Hope this helps, (^↽^)
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: clone index question

Postby savvy » Sun Apr 17, 2011 1:24 pm

thanks a bunch dark ;) 1up for you
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: clone index question

Postby lcl » Sun Apr 17, 2011 10:33 pm

Btw dark, here's more easy to use function for checking clones by index.
Code: Select all
char ACTOR[50];

Actor * getClone2(char NAME[50], int NUM)
{
    sprintf(ACTOR, "%s.%i", NAME, NUM);
    return getclone(ACTOR);
}


Example:
Code: Select all
getClone2("myActor", 5)->x = 10;


I don't remember who made this one originally, but I use it. :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest