PDA

View Full Version : Toggle...



ReT
06-21-2005, 06:54 PM
Hey,

How do I make a toggle with more than 2 options? I want to be able to put it in an activated: message and activate it once to do something, again to do something, once again to do something else, and so on. I can't figure this out, so any help would be great.

ReT

Quib Mask
06-21-2005, 07:06 PM
Well, knowing what base COG you're working with might help, but I'd do something like:
if(i == 0)
{
// do whatever
i = 1;
}
else if(i == 1)
{
// do whatever
i = 2;
}
else if(i == 2)
{
// do whatever
i = 3;
}
else
{
// do whatever
i = 0;
}The variable "i" can be whatever other word you want, and should be initialized in the symbols section as 0.

If this isn't what you're looking for, yell at me, but I thought I understood the question.

QM

darthslaw
06-21-2005, 07:07 PM
symbols

message activated
int mode=0 local

end

activated:
mode = mode + 1;
if(mode > 3) mode = 0;

if (mode == 1) do_something();
else if(mode == 2) do_something_else;
else if(mode == 3) do_that;

return;

end

That should get you started methinks :)

...d'oh Quib beat me

ReT
06-21-2005, 07:29 PM
Thanks guys, I really appreciate it.

ReT