Options

This object provides functions for compact setting and testing of up to 32 options. They can be used by softcoded systems that require toggles.

Author: Raevnos
Category: Functions
Commands: @create, @lset, @set.
Functions: band(), bnand(), bor(), member(), num(), shl(), u().
Compatibility: CobraMUSH, PennMUSH.

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Options

@create Options
@lock/Basic Options==me
@lset Options/Basic=no_inherit
&CLEAR Options=bnand(%1, shl(1, member(%0, %2)))
&CLEAR_HELP Options=u([num(me)]/clear, OPTION LIST, OPTION SET, OPTION) - Returns an option set with all the options in the second argument set except the third argument.
&DESCRIBE Options=This object provides functions for compact setting and testing of up to 32 options. They can be used by softcoded systems that require toggles.%r%rThe first argument of each function is an OPTION LIST - a case sensitive, space seperated list of all the option names. ORDER MATTERS! If 'FOO' is the third option in a list, it should always be the third option in a list. Add new options to the end of the list. Change the order only when clearing every stored option set.%r%rAn OPTION SET is the value returned by set or clear. It's a number who's set bits represent set options.%r%rAn OPTION is one item from an OPTION SET. If the OPTION is not in the OPTION SET, unpredictable results occur.%r%rThis code will not work on Penn 1.7.2 because it relies on bitwise math functions added in 1.7.3.
@set Options/DESCRIBE=no_command visual public nearby
&ISSET Options=band(%1, shl(1, member(%0, %2)))
&ISSET_HELP Options=u([num(me)]/isset, OPTION LIST, OPTION SET, OPTION) - Returns a true value if the option is set, 0 if not.
&NEWSET Options=0
&NEWSET_HELP Options=u([num(me)]/newset) returns an empty option set.
&SET Options=bor(%1, shl(1, member(%0, %2)))
&SET_HELP Options=u([num(me)]/set, OPTION LIST, OPTION SET, OPTION) returns a new option set with everything in it's second argument set, as well as the new option.

look Options