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

Game Editor comments and discussion.

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

Postby DarkParadox » Sat Feb 23, 2008 12:55 am

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)
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

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

Postby DilloDude » Sat Feb 23, 2008 2:14 am

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.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

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

Postby Game A Gogo » Sat Feb 23, 2008 2:29 am

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
}
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: toggle code not working / i'm not allowed in chat box?!?!

Postby DilloDude » Sat Feb 23, 2008 3:22 am

That also works.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

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

Postby Fuzzy » Sun Feb 24, 2008 1:08 am

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!
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: toggle code not working / i'm not allowed in chat box?!?!

Postby Game A Gogo » Sun Feb 24, 2008 3:34 am

you do know I learned that from you eh?
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: toggle code not working / i'm not allowed in chat box?!?!

Postby DilloDude » Sun Feb 24, 2008 6:22 am

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
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

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

Postby Game A Gogo » Mon Feb 25, 2008 12:05 am

even if it is shorter, I never like using that, unless I had no other choice.
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


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron