mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Is there a way for alpha.mrc and omega.mrc to both have a menu for a @window? If only one of the two scripts is loaded, that @window will show the right-click menu for that loaded script, but is there a way so that if both scripts are loaded, that only the highest loaded script's menu would appear in the rightclick menu. i.e. if both scripts had this menu in them:

menu @test {
test $scriptname :halt
}

and you want the right click menu to only have the test line showing for the topmost script, not for both of them?

thanks

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
There are a couple ways this could be accomplished.

Each relies on deciding if the current script is the topmost loaded:

Code:
alias -l showmenu {
  var %competing = FULL_FILE_PATH
  if ($script(%competing) == $null) return 1
  var %i = 1
  while (%i <= $script(0)) {
    if ($script(%i) == $script) { return 1 }
    if ($script(%i) == %competing) { return 0 }
    inc %i
  }
}


The first way to display the menu involves a conditional in the menu event, it is evaluated each time you call for the menu:

Code:
menu @window {
  $iif($showmenu,topmenu)
  .item:echo item
}


The second is to use groups, and decide which menu to show when either script is loaded:

Code:
#group1 on
menu @window {
  topmenu
  .item:echo item
}
#group1 end

on *:load:{
  if ($showmenu) {
    enable #group1
    disable #group2
  }
  else {
    disable #group1
    enable #group2
  }
}

Last edited by Loki12583; 21/11/11 06:04 AM.

Link Copied to Clipboard