EMuck Logo

EMuck Programming Macros

Macros are an "extension" of the MUF programming language. These do various functions (short-cuts) that programmers will find useful in the development of their programs.

The following list contains the system macros that are available on EMuck. Note that there may be other macros on EMuck, but the ones listed below are maintained by the EMuck Tech Administrator, lar3ry gensch.


.addspaces
( s i -- s' )

Append i spaces to string.

.appendlist
( L1 L2 -- L' )

Append two lists together. Lists are in format as follows:

( xn xn-1 xn-2 ...  x1 n )
.apply-list
( L a -- L' )

Apply the function to each item on the list, returning the modified list.

.argv0
( -- s )

Enter the first "word" on the command line typed by the user. This is (usually) the name of the command that was typed.

.atodb
( s -- d )

Convert a string to a dbref. String may be either in the format "1234" or "#1234". If not in valid format, or if the specified dbref is not valid, it returns #-1.

.calc
( s -- s )

Parse a string for a numeric expression, and calculate its value. Return the result as a string. This is used internally by Macro-50. Only works on integer expressions, and the operators +, -, * (multiplication), /, % (remainder), <, >, <=, >=, =, <> (not equal). Evaluates left to right, with no precedence. Doesn't support parenthesis either. Works very much as a calculator would work.

.charof
( s i -- s )

Return the i'th character in the string.

.check
( s1 s2 -- i )

Compare two strings, returning boolean true (1) if they are identical (case ignored), or false (0) if they are different.

.check+
( s L -- s' )

Check a list for a specific string, returning a string which matches it either exactly or partially. Returns an empty string if no match found.

.controls
( d1 d2 -- i )

Return true if d1 controls d2.

.costname
( d -- s )

Return the name of the object. If the object is wearing a @COSTUME, return its name in angle brackets (<name>), or if the costume is the OOC costume, return its name in curly brackets ({name}). Used to identify costume wearers.

.cr
( -- )

Emit a blank line.

.db2str
( d -- s )

Convert a dbref into a string in format "#1234". Functional opposite to .atodb macro.

.edit
( d s -- i )

Allow the user to edit a multi-line property. Property is stored on `d', and the prefix for the property name is `s'. Returns 0 (false) if user aborts, or 1 if user saves the changes.

.editor
( d s -- i )

Functionally identical to .edit macro.

.editor-old
( d s -- i )

Functionally identical to .edit macro (we no longer support the old Chaos editor).

.exec-or-notify
( s -- )

Checks the first character on the specified string. If it is "@", then it will attempt to execute a program (similar to the way that programs are executed on @DESC, @SUCC, and @FAIL fields). Otherwise, display the string to the user.

.exit_name
( d -- s )

Return the first name of an exit (that is, all characters up to but not including the first semi-colon).

.express
( s -- ? )

Move the user to a specific EMTrak station. This incurs costs (one ticket).

.firstname
( d -- s )

Return the first name of an exit (that is, all characters up to but not including the first semi-colon).

.fmt-all
( s -- )

Display a message to everybody in the current location, performing intelligent line wrapping and token replacement:

        <lf>      Break line intentionally at this point
        <name>    Replace with user's name
.fmt-me
( s -- )

Display a message to the user, performing intelligent line wrapping and token replacement:

        <lf>      Break line intentionally at this point
        <name>    Replace with user's name

.fmt-others
( s -- )

Display a message to everybody in the current location, except the current user, performing intelligent line wrapping and token replacement:

        <lf>      Break line intentionally at this point
        <name>    Replace with user's name

.fmt-user
( d s -- )

Display a message to the specified user (d). #-1 indicates everybody in the current location, #-2 indicates everybody in the current location except the current user. Function performs intelligent line wrapping and token replacement:

        <lf>      Break line intentionally at this point
        <name>    Replace with user's name

.fo-50?
( d s -- i )

Return true (1) if fake object named s located on d uses Macro50. Returns empty string if successful, otherwise and error message.

.fo-call
( ? i -- ? )

Internal macro used to call .fo-xxx functions.

.fo-del
( d s -- s )

Remove the fake object named s located on d. Returns empty string if successful, otherwise and error message.

.fo-desc
( d s -- )

Display description of fake object s located on d.

.fo-edit
( d s -- s )

Edit the description of fake object s located on d. Returns empty string if successful, otherwise and error message.

.fo-list
( d -- L )

Return list of fake objects on d.

.fo-match
( d s -- s' )

Find the fake object on d that best matches s.

.fo-new
( d s -- s )

Create a new fake object. Dumps the user into the editor to specify the description. Returns empty string if successful, otherwise and error message.

.fo-owner
( d s -- d )

Return the creator of fake object s in location d.

.fo-rename
( d s s' -- s )

Rename fake object s on d to s'. Returns empty string if successful, otherwise and error message.

.fo-unparse
( d s -- s )

Return an "unparsed" object name (name appended with (#) if the user controls the location d and is not SILENT). Otherwise, just returns the name of the fake object (s).

.fo-xfer
( d s d' -- s )

Transfer fake object s in location d to d'. Returns empty string if successful, otherwise and error message.

.id
( d -- s )

Display the name of the object, appending to it the dbref number and any flags (eg, #1234EH).

.idletime
( d -- s )

Returns the idle time of a player as a string, the way you would see it in a WHO listing. Doesn't check to make sure the player is awake [!].

.isadmin?
( d -- i )

Return true if player d is an administrator (Worker, Gofer, or alternate character for admin).

.isidle?
( d -- i )

Returns true if player d is online and idle.

.isminor?
( d -- i )

Returns true if player d is a minor.

.isprofane?
( s -- i )

Returns true if string is profane according to the profanity checker.

.isprofane_any?
( s -- i )

Returns true if phrase is profane if and only if there are minors in the current room.

.isprofane_recip?
( d s -- i )

Returns true if the current user or player d is a minor and the phrase s is profane.

.justify-left
( s i -- s' )

Append enough spaces to s to make it at least length i. Doesn't check if length(s) > i already.

.map-contents
( d a -- )

Run function a against all the contents of dbref d.

.map-list
( L a -- )

Run function a against each element in list L.

.match
( s -- d )

Non-setuid version of match -- used by W-bit programs to get a match without W-perms.

.moveto
( d1 d2 -- )

Identical to moveto primitive -- used for compatibility with a previous Muck.

.myname
( -- s )

Return the user's name, or @COSTUME name if wearing a costume. Doesn't identify name is being a costume (use .costname for that).

.name
( d -- s )

Return the name of d, or @COSTUME name if wearing a costume. Doesn't identify name is being a costume (use .costname for that).

.neg
( i -- -i )

Negate the number.

.nmatch
( s -- d )

Find the user whose name (or @COSTUME name) most closely matches 's'.

.odesc
( d -- s )

Get an object's @ODESC.

.onftime
( i s -- s' )

strftime for elapsed times:

        %d   day component              %D   time in days
        %h   hour component             %H   time in hours
        %m   minute component           %M   time in minutes
        %s   seconds component          %S   time in seconds
        %Bx  Blank pad 'x' component    %Zx  Zero pad 'x' component
        %i   fit as small as possible

%D, %H, %M, %S display time rounded to specified units; the lower case break up time into components. %Bx and %Zx will supply a leading blank or zero for '%x' if value is < 10. For %Bx and %Zx, x must be one of d, h, m, or s. The %i format will show the time as follows:

        #d   if over one day
        #h   if over an hour and less than a day
        #m   if over a minute and less than an hour
        #s   if less than a minute

Where '#' is the number of days, hours, minutes, or seconds.

.parseequals
( "p1=p2" -- p2 p1 )

Parse a string for two parameters, separated by an equal sign.

.pgmver
( -- s )

Return a string containing the program name, version number, and last modified date. MYVER must be defined ($def MYVER "1.0") prior to the invocation of this macro.

Example (program l3-test.muf last modified on 6-24-98):

        $def MYVER      4.0

        : start
            .pgmver .tell-me
        ;

Will emit:

        l3-test.muf(4.0) 24-Jun-98
.pmatch
( s -- d )

Return the player whose name exactly matches s.

.pmatch+
( s -- d )

Find the user whose name (or @COSTUME name) most closely matches 's'.

.popword
( "w1 w2..." -- "w2..." )

Remove the first (space-delimited) word from a string.

.private?
( d -- i )

Return TRUE if d, or d's location, is UNFINDABLE or if d is DARK.

.randint
( i -- i' )

Return a random integer (0..i-1) -- a more stable random value than using: random swap %

.readeditor
( d s -- )

Display an multi-value property (Muck Editor format) on object d with property prefix s. Output is to the user.

.setodesc
( d s -- )

Set an object's @ODESC.

.shell-sort-list
( L [a] i -- L' )

This shell sort implementation is based on the version in AHU's Data Structures and Algorithms, p.290 The algorithm is O[n^1.5] worst case and about O[n^1.27] for pure random data. This implementation works purely on the data stack, so it is reasonably fast, and can be called by any other program. My test data indicates that this implementation scales about like O[n^1.37] or so.

Takes ( x1 x2 x3 ... xn n index -- x1' x2' x3' ... xn' n )

The index selects both the type of data to be sorted, as well as how it is to be sorted. Ascending order means that the smallest numbered items are neasest the top of the stack. [And hence will be the first to be printed out later.]

Valid choices are:

Index  Name         Description
  0    SortStrACI   String Data,  Ascending, Case Insensitive
  1    SortStrACS   String Data,  Ascending, Case Sensitive
  2    SortIntA     Integer Data, Ascending
  3    SortStrDCI   String Data,  Descending, Case Sensitive
  4    SortStrDCS   String Data,  Descending, Case Insensitive
  5    SortIntD     Integer Data, Descending
  6    SortGen      Pass your own ordering function under the index

The .shell-sortxxx macros are useful for specifying the index values.

.shell-sortgen
( -- i )

Constant for .shell-sort-list. Pass your own ordering function under the index.

.shell-sortinta
( -- i)

Constant for .shell-sort-list. Integer data, ascending

.shell-sortintd
( -- i)

Constant for .shell-sort-list. Integer data, descending

.shell-sortstraci
( -- i)

Constant for .shell-sort-list. String data, ascending, case insensitive

.shell-sortstracs
( -- i)

Constant for .shell-sort-list. String data, ascending, case sensitive

.shell-sortstrdci
( -- i)

Constant for .shell-sort-list. String data, descending, case sensitive

.shell-sortstrdcs
( -- i)

Constant for .shell-sort-list. String data, descending, case insensitive

.sort-list ( L a -- L' )

Shell Sort list L using comparison routine a.

.space
( s i -- s' )

Append enough spaces to s to make it at least length i. Doesn't check if length(s) > i already.

.sps
( s -- s' )

Strip leading blanks from s.

.strftime
( s i -- s' )

Fix for bug in strftime primitive that doesn't give proper am/pm output.

.sts
( s -- s' )

Strip trailing spaces from s.

.tell
( s -- )

Display string s to the user.

.tell-everybody
( s -- )

Display string s to everybody in the current room.

.tell-me
( s -- )

Display string s to the user.

.tell-others
( s -- )

Display string s to everybody in the current room except the current user.

.termheight
( -- i )

Return the number of lines in the user's display (as set in @SETINFO).

.termwidth
( -- i )

Return the number of columns in the user's display (as set in @SETINFO).

.tolower
( S -- s' )

Convert S to lower case.

.tp.callprog
( i -- ? )

Macro used to provide .tp.xxxx functions.

.tp.ctime
( i -- s )

Convert time i to standard format (relative to Muck).

.tp.datefmt
( -- s )

Return a standardized strftime format string for dd-mmm-yy.

.tp.gmtime
( -- s )

Convert time i to standard format (relative to UTC).

.tp.gmtmktime
( y m d H M S -- i )

Convert a date/time into a time reference (relative to UTC).

.tp.localmktime
( y m d H M S -- i )

Convert a date/time into a time reference (relative to user).

.tp.localtime
( i -- s )

Convert time i to standard format (relative to user).

.tp.mktime
( y m d H M S -- i )

Convert a date/time into a time reference (relative to muck).

.tp.strftimegmt
( i s -- s' )

strftime, relative to UTC.

.tp.strftimelocal
( i s -- s' )

strftime, relative to user.

.tp.strftimemuck
( i s -- s' )

strftime, relative to muck.

.tp.strftimeuser
( d s i -- s' )

strftime, relative to user d.

.tp.timezonegmt
( -- s )

UTC's time zone (always "UTC")

.tp.timezonelocal
( -- s )

User's local time zone.

.tp.timezonemuck
( -- s )

Muck's time zone.

.tp.timezoneuser
( d -- s )

Time zone relative to user d.

.trace-off
( -- )

Turn of program debugging. Only works if person running program controls the program.

.trace-on
( -- )

Turn on program debugging. Only works if person running program controls the program.

.trim_spaces
( s -- s' )

Remove spaces from beginning and end of the string.

.unparseobj
( d -- s )

Calls unparseobj primitive (for compatibility with some other mucks).

.uptime
( -- i )

Return the number of seconds since the game server was last started.

.wizard?
( d -- i )

Is d a WORKER or GOFER and not QUELL'ed?

.wizmatch
( s -- s' )

Do a `match' primitive, but with WORKER privs.

.wrap-all
( s -- )

Display a message to everybody in the current location, performing intelligent line wrapping.

.wrap-me
( s -- )

Display a message to the user, performing intelligent line wrapping.

.wrap-others
( s -- )

Display a message to everybody in the current location, except the current user, performing intelligent line wrapping.

.wrap-user
( d s -- )

Display a message to the specified user (d). #-1 indicates everybody in the current location, #-2 indicates everybody in the current location except the current user. Function performs intelligent line wrapping.