a toggle switch for menus

By Joystyk on Mar 12, 2007

This little snippet makes for a simple enable/disable section on your menu in which it will tell you weather the section is active, or not. It's useful in large bulky scripts with alot of menu items.

With that said, Enjoy.

menu status {
  .Section ( $+ %sectionstatus $+ ) { 
    if ( %sectionstatus == off ) { //set %sectionstatus on | .enable #section } 
    elseif ( %sectionstatus == on ) { //set %sectionstatus off | .disable #section }
  }

}

#section off

on *:TEXT:*hi*:#: { //msg $chan Hi $nick $+ ! } 
;this is where the section to toggle goes.

#section end

Comments

Sign in to comment.
no_body21   -  Mar 13, 2007

menu status {
.Section $+($chr(40),$iif($group(#section) == on,Enabled,Disabled),$chr(41)):{
$iif($group(#section) == on,.disable,.enable) #section
}

 Respond  
Acid-Religion   -  Mar 13, 2007

You could clean up the code, like removing the halt as they are not needed here. Also, why do you use // as command prefix?
And dead also gave you a good tip on how to improve the code by atleast 2 points. But your general idea is pretty good, and I am seeing this could be useful to some ppl...

 Respond  
Korvin   -  Mar 12, 2007

menu status {
.Section ( $+ %sectionstatus $+ ) {
if ( %sectionstatus == off ) { //set %sectionstatus on | .enable #section | halt }
elseif ( %sectionstatus == on ) { //set %sectionstatus off | .disable #section | halt }

that halts the return messege.

 Respond  
_dead   -  Mar 12, 2007

Section $+($chr(40),$group(#section).status,$chr(41)): { if ($group(#section).status == on) { disable #section | halt } | if ($group(#section).status == off) { enable #section | halt } }

 Respond  
Joystyk   -  Mar 12, 2007

I can\'t remember how to halt the default message for announcing that groups are enabled/disabled. Bear with me. :P

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.