if statement problem

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

if statement problem

Postby 157pl » Wed Dec 22, 2010 10:51 pm

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?
User avatar
157pl
 
Posts: 109
Joined: Thu May 13, 2010 10:49 pm
Location: AZ
Score: 3 Give a positive score

Re: if statement problem

Postby 157pl » Wed Jan 05, 2011 3:06 pm

i must have a bad problem if its ben 2 weeks and i cant get help :lol:
User avatar
157pl
 
Posts: 109
Joined: Thu May 13, 2010 10:49 pm
Location: AZ
Score: 3 Give a positive score

Re: if statement problem

Postby AliceXIII » Wed Jan 05, 2011 3:17 pm

well it's kinda hard to understand your first post? :P
"Taking a breath of fresh air."
User avatar
AliceXIII
 
Posts: 325
Joined: Fri Sep 17, 2010 2:36 am
Location: victoria, texas
Score: 37 Give a positive score

Re: if statement problem

Postby lcl » Wed Jan 05, 2011 5:45 pm

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. :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: if statement problem

Postby 157pl » Mon Jan 10, 2011 2:41 pm

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
User avatar
157pl
 
Posts: 109
Joined: Thu May 13, 2010 10:49 pm
Location: AZ
Score: 3 Give a positive score

Re: if statement problem

Postby schnellboot » Mon Jan 10, 2011 3:06 pm

I don't understand what you mean with 18 & 10
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: if statement problem

Postby Bee-Ant » Mon Jan 10, 2011 4:38 pm

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
}
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: if statement problem

Postby 157pl » Tue Jan 11, 2011 3:19 pm

would that code work on all of them because it keeps making them
User avatar
157pl
 
Posts: 109
Joined: Thu May 13, 2010 10:49 pm
Location: AZ
Score: 3 Give a positive score

Re: if statement problem

Postby Bee-Ant » Tue Jan 11, 2011 3:44 pm

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
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: if statement problem

Postby Game A Gogo » Tue Jan 11, 2011 9:12 pm

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
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: if statement problem

Postby 157pl » Mon Mar 14, 2011 8:02 am

thanks everyone sorry im kinda late busy with school
User avatar
157pl
 
Posts: 109
Joined: Thu May 13, 2010 10:49 pm
Location: AZ
Score: 3 Give a positive score

Re: if statement problem

Postby Fuzzy » Tue Mar 22, 2011 6:10 am

I think you are inviting a nasty bug in. What happens if there is no player.18? Crash.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: if statement problem

Postby Bee-Ant » Tue Mar 22, 2011 6:29 am

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.
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: if statement problem

Postby Fuzzy » Tue Mar 22, 2011 6:39 am

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.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: if statement problem

Postby Bee-Ant » Tue Mar 22, 2011 6:44 am

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
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron