usage/Default Command

Menus may have a default command. This is a command which gets run if a menu item with no command is executed. This may not sound very useful on its own, but default commands are run through a substituion pass where the special "<LABEL>" string is replaced with the label of the menu item being executed.

To set a default command on a menu:

/sms menu mymenu defcmd "/do this default command"

To remove the default command:

/sms menu mymenu defcmd ""

To see the default command on a menu, if any, you can use sms menu <menu-name>.

A useful example (assumes you have a plugin which provides a /warp command, and have created named warp points warp1, warp2, warp3):

/sms create warps &1-Warp Points-
/sms menu warps "/warp <LABEL>"
/sms add warps warp1
/sms add warps warp2
/sms add warps warp3

Since each item has no command, only a label, the default command is run whenever an item is selected. That command is /warp <LABEL>, which is substituted depending on which item is selected. E.g. if you select warp1, the command /warp warp1 will be run.

Any formatting codes in the label will be stripped when using <LABEL>. E.g. if you have a menu item like:

/sms add warps &4warp4

then the item label will appear red in the view, but the string "warp4" will be substituted for <LABEL>.

If you want the label to be passed unchanged, with all formatting codes intact, then use <RAWLABEL> instead.


Posts Quoted:
Clear All Quotes