Common MUF Macros


Error message:  "Undefined word <word>"
Macros are little snippets of MUF code which are installed on the server and can then be called from any MUF program.  Any player with an M bit may make public macros.  Macros are called from within programs by using the macro name preceded by a period: for instance, to call the common public macro tell, a programmer would insert the word .tell into her program.  Some macros require arguments or call programs which may not exist on your MUCK; where possible, program names and owners have been listed beside program calls.  Ask the program owner for permission to port, and be sure to change the database number in the macro to the database number of the appropriate program on your MUCK.

To install a macro, enter the program editor (type "@edit <any program name>"), and type

def <macroname> <macrobody>
for example: def tell me @ swap notify will define the macro "tell" as the MUF code "me @ swap notify".

addpropstr       MamaKhat          dup not if pop remove_prop else 0 addprop then
after_match      Kahz              ( d -- ) dup #-1 dbcmp if pop exit then dup #-2 dbcmp if pop exit then pop
atodbref         Kahz              ( s -- d ) "" "#" subst atoi dbref
blank?           Kahz              "" strcmp not
broadcast        Kahz              ( s -- ) #2056 call  (pose-broadcaster - FurToonia)
commas           Mara              ( s -- s' ) striplead striptail begin dup " " instr while " " "  " subst repeat ", " " " subst dup "," rinstr dup if 1 - strcut ", and " ", " subst strcat else pop then
compress         Kahz              #196 call (compress.muf - FurToonia)
confirm          MamaKhat          ( s -- i ) ( displays query string and waits for user input-- returns 1 if user said "y" ) me @ swap notify read 1 strcut pop "y" stringcmp not
control?         Squirrelly        ( d -- i ) ME @ swap .controls
controls         Squirrelly        ( d d -- i ) over ok? over ok? and if controls else pop pop 0 then
cr               Unknown           me @ " " notify
debug-line       MamaKhat          ( -- ) prog "!d" over "d" set set (shows a single debug line)
debug-off        MamaKhat          ( -- ) prog "!D" set ( set a program !debug from this line )
debug-on         MamaKhat          ( -- ) prog "D" set ( set a program debug from this line )
decr             Caitlin           1 -
envprop          Kahz              envpropstr swap pop
envsearch        Squirrelly        ( d s -- d ) envpropstr pop
flaglist         Kahz              ( d -- s )  (Returns a string of the object's flags)  #694 call
getenvprotect    Squirrelly        ( d s -- s ) over over "_" swap strcat .envprop dup if swap pop swap pop else pop .envprop then
getprotect       Squirrelly        ( d s -- s ) over over "_" swap strcat getpropstr dup if swap pop swap pop else pop getpropstr then
hasflag?         Squirrelly        ( d s -- i ) ( like flag?, but <s> can be multiple single char flags; returns true if <d> has any of them set ) 0 swap begin dup while 1 strcut swap 4 pick swap flag? rot or swap repeat pop swap pop
incr             Caitlin           1 +
ldisplay         Ceannan           (si ... s1 i -- ) (Displays i strings from the stack, starting from the *bottom* one.) begin dup 0 > while dup 1 + rotate .tell 1 - repeat pop
letter?          Saurian           "[a-z]" smatch
max              Squirrelly        ( i i -- i ) over over < if swap then pop
max_pennies      Squirrelly        ( -- i ) "max_pennies" sysparm atoi
mdisplay         Squirrelly        ( s -- ) ( like .tell, but calls a program if <s> starts with an @-sign ) .sqfuncs "mdisplay" call
me_wiz?          Kahz              me @ "Wizard" flag?
min              Squirrelly        ( i i -- i ) over over > if swap then pop
muckerlevel      Kahz              ( d -- i ) dup "Wizard" flag? if mlevel if 4 else 0 then else mlevel then
nl               Squirrelly        ( -- s ) ( returns a single MPI newline character ) .sqfuncs "nl" call
nl-repl          Squirrelly        ( s1 s2 -- s ) ( replaces all hard-coded newline characters in s1 with s2 ) .sqfuncs "nl-repl" call
no?              Squirrelly        ( s -- i ) (checks that string starts with "n", is "0", or is blank) dup if dup 1 strcut pop "n" stringcmp not if pop 1 else "0" strcmp not then else pop 1 then
noisy_match_result Kahz              ( s -- d ) match dup #-1 dbcmp if me @ "I don't see that here." notify then dup #-2 dbcmp if me @ "I don't know which one you mean!" notify then dup #-3 dbcmp if pop me @ getlink then
nop              Caitlin           version pop
notify_nospam    Kahz              (d1 d2 s -- ) (as notify_except, but excludes all set "_nospam?:yes")  1 4 pick contents begin dup ok? not if pop break then dup player? over "_nospam?" getpropstr "yes" strcmp not and if swap 1 + rot swap 3 pick then next repeat swap notify_exclude
null?            Squirrelly        ( s -- i ) not
nullexplode      Saurian           begin dup strlen 1 - strcut swap dup not until pop
nullstr?         Virgil            not
num-players      Kahz              (returns number of players in contents or room) (d -- i) contents 0 swap begin dup ok? not if break then dup player? if swap 1 + swap then next repeat pop
objexit          Alexis            #1077 (Objexit.muf - FurToonia)
omatch           Kahz              #281 call (Omatch.muf - FurToonia))
omdisplay        Kahz              ( s -- ) ( displays an o-message to the room [q.v. omsg-sub] ) .omsg-sub .otell
otell            MamaKhat          loc @ me @ rot notify_except ( s -- ) (Display string to everyone in my room except me )
padinstr         Kahz              " " strcat " " swap strcat swap " " strcat " " swap strcat swap instr
padinstring      Kahz              " " strcat " " swap strcat swap " " strcat " " swap strcat swap instring
pmatch           MamaKhat          (s -- d) #7 call (def-pmatch - FurToonia)
pmatch+          Squirrelly        ( s -- d ) ( pmatch+; pmatch with partial name matching ) .sqfuncs "pmatchplus" call
pmatch-f         Squirrelly        ( s -- d ) ( pmatch-free; pmatch with a penny rebate ) .pmatch .MAX_PENNIES ME @ owner pennies - "lookup_cost" sysparm atoi .min dup 0 > if ME @ owner swap addpennies else pop then
popn             Kahz              ( x[1] x[2] ... x[n] n -- ) #377 call (popn.muf - FurToonia)
printf           Caitlin           me @ swap notify
private?         Mystique          "_teleport_allow?" getpropstr "n" instring 1 =
quote            Squirrelly        ( s -- s ) "\"" swap strcat "\"" strcat
quote_string     Squirrelly        ( s -- s ) "\"" swap strcat "\"" strcat
rstrfmt          Squirrelly        ( s i -- s ) swap .spc80 swap strcat swap over strlen swap - strcut swap pop
safecall         Squirrelly        ( xi ... x2 x1 d i -- ) ( a "stack safe" call ) .sqfuncs "safecall" call
sedit_std        Kahz              1 #420 call (string-edit.muf - FurToonia) (strings... count -- strings... count exitcmd)
seeflags?        Squirrelly        ( d -- i ) dup .control? swap "ACL" .hasflag? or
sls              Kahz              striplead
sort             Unknown           ( {x} -- {x'} ) #17376 call (def-sort -- Ruffin)
split            Kahz's            (s s -- s s ) #153 call (gen-split - Slipstream)
split2           Squirrelly        ( s s1 -- s2 s3 ) ( just like .split except that s2 and not s3 will be null if s1 is not found in s ) over over instr dup 1 < if pop pop "" swap else rot swap 1 - strcut rot strlen strcut swap pop then
sps              Unknown           striplead
sqfuncs          Squirrelly        #2219 (sq-funcs.muf - Squirrelly)
strfmt           Squirrelly        ( s i -- s ) swap .spc80 strcat swap strcut pop
stripspaces      Kahz              strip
sts              Kahz              striptail
tell             MamaKhat          me @ swap notify
tell-call        Kahz              #508 call (tell-call.muf - FurToonia)
tell-me          Kahz              me @ swap notify
tellroom         Mara              ( s -- ) (Display string to everyone in my room, including me.) loc @ 0 rot notify_exclude
unparseobj       Squirrelly        ( d -- s ) dup .seeflags? if unparseobj else name then
vehicle_ok?      Azure             ( d -- i ) dup "_vehicle_ok?" getpropstr .yes? over "vehicle_ok?" getpropstr .yes? or over "_vok?" getpropstr .yes? or swap "vok?" getpropstr .yes? or
window           Kahz              #692 (Window.muf - FurToonia)
wizard?          Squirrelly        ( d -- i ) "Wizard" flag?
wizmatch         Squirrelly        ( s -- d ) .sqfuncs "wizmatch" call
xansplit         Ruffin            #153 call (gen-split - Slipstream)
yes?             MamaKhat          ( s -- i ) ( checks that string starts with y ) 1 strcut pop "y" stringcmp not
yes_envprop?     Kahz              ( o s -- b ) .envprop .yes?

Macros blatantly stolen from FurToonia.  Be sure to ask permission before porting non-public-domain programs.

Pages and art ©2002 J "Ginger" Willard: muck@soappuppy.com