TinyMUX

@function

Commands

COMMAND: @function/<switches> [<function>=<object>/<attr>]

This command displays a list of currently-defined global functions or adds a new global function named <function>. When invoked, the arguments to the function are loaded into %0-%9, the <attr> attribute from <object> is fetched, and substitution is performed on the resulting text. The result of that substitution is returned as the function result.

If no arguments are given, or if the /list switch is given, the command displays a list of the currently-defined global functions. /privileged functions are indicated with a ‘W’, /preserve functions are indicated with a ‘p’, and /restrict functions are indicated with an ‘R’.

If the /privileged switch is given, then the new global function is evaluated as if the evaluation were being performed by the object on which it is stored, instead of as if it were being performed by the invoker of the function. This may be used to allow access to information normally available only to wizards.

The /preserve switch causes r-registers to be preserved across the defined function, so you can feel free to use registers in the code without worrying about them overwriting previous definitions.

The /restrict switch makes the function callable only by wizard code. This includes code running on objects that have inherited wizard privileges (INHERIT flag on a wizard-owned object). Mortals who call a restricted function directly will receive #-1 PERMISSION DENIED. This is useful for library functions that should be available to privileged softcode but not exposed to players. /restrict may be combined with /privileged and /preserve.

The /delete switch removes an existing user-defined function.

The function definitions created by @function are not stored in the database, so they need to be re-created each time the MUX is started. It is recommended that the Startup attribute for player #1 include code to set up all global functions.

This command may normally only be invoked by player #1.