Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Toggle...
Toggle...
2005-06-21, 3:54 PM #1
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
2005-06-21, 4:06 PM #2
Well, knowing what base COG you're working with might help, but I'd do something like:
Code:
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
2005-06-21, 4:07 PM #3
Code:
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
May the mass times acceleration be with you.
2005-06-21, 4:29 PM #4
Thanks guys, I really appreciate it.

ReT

↑ Up to the top!