Page 1 of 1

if statement problem

PostPosted: Wed Dec 22, 2010 10:51 pm
by 157pl
how can i check a variable of a clone if i need to have the clone being checked 8 more in the clone index than the clone that is checking it?

Re: if statement problem

PostPosted: Wed Jan 05, 2011 3:06 pm
by 157pl
i must have a bad problem if its ben 2 weeks and i cant get help :lol:

Re: if statement problem

PostPosted: Wed Jan 05, 2011 3:17 pm
by AliceXIII
well it's kinda hard to understand your first post? :P

Re: if statement problem

PostPosted: Wed Jan 05, 2011 5:45 pm
by lcl
AliceXIII wrote:well it's kinda hard to understand your first post? :P

Other thing is that this kind of things don't belong to advanced topics, but into game development or support. :D
157pl wrote:how can i check a variable of a clone if i need to have the clone being checked 8 more in the clone index than the clone that is checking it?

You know "the clone that is checking it" is every single clone of that same actor in your game, if you haven't done it so just one of them does that checking.
Could you explain more about your problem, please? Then I could help you. :)

Re: if statement problem

PostPosted: Mon Jan 10, 2011 2:41 pm
by 157pl
well say i had an actor named player.10
then i would need to wright an if statement to see if var1 = 1 on player.18
my only problem is that it needs to work with any actor

did that help

Re: if statement problem

PostPosted: Mon Jan 10, 2011 3:06 pm
by schnellboot
I don't understand what you mean with 18 & 10

Re: if statement problem

PostPosted: Mon Jan 10, 2011 4:38 pm
by Bee-Ant
157pl wrote:how can i check a variable of a clone if i need to have the clone being checked 8 more in the clone index than the clone that is checking it?

Add this code on Player.10 to check the state.
Code: Select all
Actor *check;
char str[32];

sprintf(str,"Player.%i",18);
check=getclone(str);

if(check->var1==1 && cloneindex==10) //if current player cloneindex is 10 and check (player.18) var1 is 1
{
    //do something here
}

Re: if statement problem

PostPosted: Tue Jan 11, 2011 3:19 pm
by 157pl
would that code work on all of them because it keeps making them

Re: if statement problem

PostPosted: Tue Jan 11, 2011 3:44 pm
by Bee-Ant
157pl wrote:would that code work on all of them because it keeps making them

Since they're clones, that's right...the code will be applied to all of them.
Buttt, since you have the IF statement, that code only work for player.10

Re: if statement problem

PostPosted: Tue Jan 11, 2011 9:12 pm
by Game A Gogo
here: (Taken from Bee-ant!)
Code: Select all
Actor *check;
char str[32];
sprintf(str,"Player.%i",cloneindex+8);
check=getclone(str);

if(check->var1==1)
{
    //do something here
}


he wanted the code to work for every clone, so that a clone would fetch a variable from 8 clones behind

Re: if statement problem

PostPosted: Mon Mar 14, 2011 8:02 am
by 157pl
thanks everyone sorry im kinda late busy with school

Re: if statement problem

PostPosted: Tue Mar 22, 2011 6:10 am
by Fuzzy
I think you are inviting a nasty bug in. What happens if there is no player.18? Crash.

Re: if statement problem

PostPosted: Tue Mar 22, 2011 6:29 am
by Bee-Ant
Fuzzy wrote:I think you are inviting a nasty bug in. What happens if there is no player.18? Crash.

You're talking to who?
Me or Gogo?

Whichever the case, getclone() won't give a crash although the requested clone number doesn't exist.

Re: if statement problem

PostPosted: Tue Mar 22, 2011 6:39 am
by Fuzzy
Ah, I guess I am getting too used to python. It would return the object, and you can test those against a boolean. I expected that C would return null instead of none.

Re: if statement problem

PostPosted: Tue Mar 22, 2011 6:44 am
by Bee-Ant
Fuzzy wrote:Ah, I guess I am getting too used to python. It would return the object, and you can test those against a boolean. I expected that C would return null instead of none.

A lame excuse :P :P :P