Page 1 of 1

Multiple conditions

PostPosted: Sat Nov 22, 2008 3:47 pm
by brandov
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?

Re: Multiple conditions

PostPosted: Sat Nov 22, 2008 7:56 pm
by skydereign
Like this, there is a description of these on the gE wiki.
if (var1==1 && var2==2)
{
do stuff;
}

Re: Multiple conditions

PostPosted: Sun Nov 23, 2008 3:11 am
by Fuzzy
Put the mostly likely to vary first. if it is false the computer will abort the second test, saving some processor time.

Re: Multiple conditions

PostPosted: Tue Nov 25, 2008 11:31 pm
by brandov
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.

Re: Multiple conditions

PostPosted: Wed Nov 26, 2008 12:02 am
by Killagram
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;
}