Multiple conditions

Non-platform specific questions.

Multiple conditions

Postby brandov » Sat Nov 22, 2008 3:47 pm

Hi, i know this has been posted before somewhere, but i couldn't seem to find it.
anyways, how do you script something so as that it requires mulitple things to be true for the actions to be performed?

AKA,
if (var1==1)
if(var2==1)
{
do a bunch of stuff
}
...but how do i get it to include BOTH variables in it's check?
Last edited by brandov on Sun Nov 23, 2008 1:53 am, edited 1 time in total.
Hi! I've been using Game Editor since it came out, but I am shy and don't post much on the forums!
http://www.vivianvideo.com
User avatar
brandov
 
Posts: 6
Joined: Wed Oct 03, 2007 10:43 pm
Location: Michigan, USA
Score: 0 Give a positive score

Re: Multiple conditions

Postby skydereign » Sat Nov 22, 2008 7:56 pm

Like this, there is a description of these on the gE wiki.
if (var1==1 && var2==2)
{
do stuff;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Multiple conditions

Postby Fuzzy » Sun Nov 23, 2008 3:11 am

Put the mostly likely to vary first. if it is false the computer will abort the second test, saving some processor time.
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: Multiple conditions

Postby brandov » Tue Nov 25, 2008 11:31 pm

Thanks :D that worked well.
I have another question related to this topic though...

in the code i'm using,

Code: Select all
if(prest == 0)
{
   CreateTimer("Event Actor", "barely", 12);
   prest = 1;
};
if(prest == 1)
{
    CreateTimer("Event Actor", "barelys2", 12);
    prest = 2;
    ChangeTransparency("tut_st_y", 1.000000);
    EventDisable("tut_st_n", EVENTKEYDOWN);
    EventEnable("Event Actor", EVENTKEYDOWN);
};
if(prest = 2)
{
    prest = 3;
};


it seems to do all the actions at once. Is it actually doing this, and if so, how do i ensure they stay seperate? or is there no errors here and should i look elsewhere for the problem? btw, this is the result of a activation event from another actor's key down event, which is set to repeat disable, and has a timer before it can be pressed again to send another activation event here so there is time between the checks for the different states of the variables. (it controls a text actor, so i want them to have time to read it.) if that helps any. I'm rather new at using MULTIPLE conditions in one script, if you couldn't tell :P

PS the timers in THIS script are just used to make this actor change it's own text. they aren't related to the time allowed between key presses.
Hi! I've been using Game Editor since it came out, but I am shy and don't post much on the forums!
http://www.vivianvideo.com
User avatar
brandov
 
Posts: 6
Joined: Wed Oct 03, 2007 10:43 pm
Location: Michigan, USA
Score: 0 Give a positive score

Re: Multiple conditions

Postby Killagram » Wed Nov 26, 2008 12:02 am

Code: Select all
switch (prest)
{
case 0:
   CreateTimer("Event Actor", "barely", 12);
   prest = 1;
break;

case 1:
    CreateTimer("Event Actor", "barelys2", 12);
    ChangeTransparency("tut_st_y", 1.000000);
    EventDisable("tut_st_n", EVENTKEYDOWN);
    EventEnable("Event Actor", EVENTKEYDOWN);
    prest = 2;
break;

case 2:
    prest=3;
break;

}


also dont need a ; after a }, only after a statement
Code: Select all
if (this)
{
then that;
}
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
-Brian W. Kernighan
User avatar
Killagram
 
Posts: 31
Joined: Sun Aug 10, 2008 8:49 pm
Score: 5 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron