M6: Flag macro conditional and commands

The [flag] conditional and the /setflag command allow custom user-modifiable state to be introduced into macro command options. As an example, the following macro normally casts Battle Shout, but after being right clicked, will switch to always casting Commanding Shout:

/setflag [btn:2] command /cast [flag:command] Commanding Shout; Battle Shout

Checking flag state

The [flag] macro conditional can be used to query flag state. Flags are identified by their name, and may have an assigned value (as opposed to a binary set/cleared state).

  • [flag:foo] is true when flag foo is set.
  • [noflag:foo] is true when flag foo is cleared.
  • [flag:foo=bar] is true when flag foo is set to the value bar.
  • [noflag:foo=bar] is true when flag foo is cleared, or set to any other value than bar.

You may use the usual /alternative syntax with this conditional:

  • [flag:foo/bar] is true when one or both of flags foo and bar are set.
  • [noflag:foo/bar] is true when neither of flags foo and bar are set.

Changing flag state

The /setflag macro command can be used to set or clear flag values. You may use extended macro options to specify the arguments to this command.

  • /setflag foo sets flag foo to a non-specific value.
  • /setflag foo=bar sets flag foo to value bar.
  • /setflag foo= clears flag foo

The /cycleflag macro command advances the value of a flag conditional. You may use extended macro options to specify the arguments to this command.

  • /cycleflag foo toggles flag foo: if set, it is cleared, if cleared, it is set.
  • /cycleflag foo=ceiling increments the value of flag foo by 1 (a cleared flag is set to 1); if it reaches ceiling, the flag is cleared.
  • /cycleflag foo=ceiling+step increases the value of flag foo by step, modulo ceiling.
  • /cycleflag foo=ceiling-step decreases the value of flag foo by step, modulo ceiling.

The /randflag macro command sets the flag to a random value within the specified range. You may use extended macro options to specify the arguments to this command.

  • /randflag foo<top selects an integer value between 0 and top, and sets flag foo to that value (if 0 is selected, the flag is cleared instead).

More examples

To let right-clicking the macro toggle between casting Battle Shout and Commanding Shout, use

/setflag [btn:2,noflag:command] command; [btn:2] command= /cast [flag:command] Commanding Shout; Battle Shout

This could also be implemented using /cycleflag:

/cycleflag [btn:2] command /cast [flag:command] Commanding Shout; Battle Shout