Page 1 of 1

toggle code not working / i'm not allowed in chat box?!?!

PostPosted: Sat Feb 23, 2008 12:55 am
by DarkParadox
Here's the toggle code:
Code: Select all
if(toggle == 1)
{
    ChangeAnimation("Event Actor", "eye-on", FORWARD);
    toggle = 2;
}
if(toggle == 2)
{
    ChangeAnimation("Event Actor", "eye-off", FORWARD);
    toggle = 1;
}


and the chat box, ERROR MESSAGE:

[phpBB Debug] PHP Notice: in file /chat/lib/class/AJAXChat.php on line 1993: session_start() [function.session-start]: open(/var/lib/php/session/sess_qrhof38o8cpsbkm6barc55pjb1, O_RDWR) failed: Permission denied (13)

Re: toggle code not working / i'm not allowed in chat box?!?!

PostPosted: Sat Feb 23, 2008 2:14 am
by DilloDude
For a toogle like that, it's best to use a switch:
Code: Select all
switch (toggle)
{
    case 1:
    ChangeAnimation("Event Actor", "eye-on", FORWARD);
    toggle = 2;
    break;

    case 2:
    ChangeAnimation("Event Actor", "eye-off", FORWARD);
    toggle = 1;
    break;
}

Make sure that toggle is either 1 or 2 when you use it, or else nothing will happen.

Re: toggle code not working / i'm not allowed in chat box?!?!

PostPosted: Sat Feb 23, 2008 2:29 am
by Game A Gogo
I had already solved this with him over AIM, here is the code I used:
Code: Select all
toggle=!toggle;
if(toggle==1)
{
//etc
}
else if(toggle==0)
{
//etc
}

Re: toggle code not working / i'm not allowed in chat box?!?!

PostPosted: Sat Feb 23, 2008 3:22 am
by DilloDude
That also works.

Re: toggle code not working / i'm not allowed in chat box?!?!

PostPosted: Sun Feb 24, 2008 1:08 am
by Fuzzy
Game A Gogo wrote:I had already solved this with him over AIM, here is the code I used:
Code: Select all
toggle=!toggle;
if(toggle==1)
{
//etc
}
else if(toggle==0)
{
//etc
}



I like that! good job!

Re: toggle code not working / i'm not allowed in chat box?!?!

PostPosted: Sun Feb 24, 2008 3:34 am
by Game A Gogo
you do know I learned that from you eh?

Re: toggle code not working / i'm not allowed in chat box?!?!

PostPosted: Sun Feb 24, 2008 6:22 am
by DilloDude
Theoretically, if you've just said toggle = !toggle, toggle sjould eithe be 0 or 1, so you wouldn't necessarily need the second if. You could just use if (toggle)...else

Re: toggle code not working / i'm not allowed in chat box?!?!

PostPosted: Mon Feb 25, 2008 12:05 am
by Game A Gogo
even if it is shorter, I never like using that, unless I had no other choice.