Kareila's Multi Descer

From Gwen Morse's Wiki
Jump to: navigation, search
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; FROM: http://www.chaoticmux.org/~kareila/TF/
;;; TF multidescer coded by Kareila@ChaoticMUX, May 2003
;;;
;;; Syntax: /showdescs, /listdescs, /showdesc <desc>, /setdesc [<obj>=]<desc>
;;;
;;; To add a desc: /set desc_<descname> <description> (see examples below)
;;;
;;; World specific adjustment and @dolist list support by Gwen Morse.

; Descriptions start here (descs "have" to come before the commands)

/set desc_testa %r[space(5)]the first short and boring test description
/set desc_testb the second short and boring test description
/set desc_testc This is a really long and boring test description.  The \
    real purpose of this description is to demonstrate how descriptions that \
    are broken across multiple lines need to be continued with backslashes \
    in order for the file to parse correctly.  The extra spaces at the \
    beginnings of lines are parsed out by TF.
 
; Commands are defined here

/def helpdescs = \
    /echo  %; \
    /echo Syntax: /showdescs, /listdescs, /showdesc <desc>, /setdesc [<obj>=]<desc>

/def showdescs = /showdescs_ $(/listvar -mglob -s desc_${world_name}_*)

/def showdescs_ = \
    /while ({#}) \
        /test regmatch('^desc_${world_name}_',{1}) %; \
        /showdesc %PR %; /shift %; \
    /done

/def listdescs = /listdescs_ $(/listvar -mglob -s desc_${world_name}_*)

/def listdescs_ = \
    /while ({#}) \
        /test regmatch('^desc_${world_name}_',{1}) %; \
        /set listdescs_temp %{listdescs_temp} %PR %; /shift %; \
    /done %; \
    /echo Available descriptions: %{listdescs_temp} %; /unset listdescs_temp

/def showdesc = \
    /if ($(/eval /echo %%desc_${world_name}_%*) =~ '') \
        /echo %% showdesc: No such description "%*". %;\
    /else \
        /eval /echo -p @{h}%*:@{n} %%desc_${world_name}_%* %; \
    /endif

/def setdesc = \
    /if (regmatch('=',{*})) \
        /if ($(/eval /echo %%desc_${world_name}_%PR) =~ '') \
            /echo %% setdesc: No such description "%PR". %; \
        /else \
            /echo %% Setting description "%PR" on object "%PL". %; \
            /eval /send @desc %PL = %%desc_${world_name}_%PR %; \
            /eval /send @dolist [num(%PL)] = %%desc_list_${world_name}_%PR %; \
        /endif %; \
    /elseif ($(/eval /echo %%desc_${world_name}_%*) =~ '') \
        /echo %% setdesc: No such description "%*". %; \
    /else \
        /echo %% Setting description "%*". %; \
        /eval /send @desc me = %%desc_${world_name}_%* %; \
    /eval /send @dolist [num(me)] = %%desc_list_${world_name}_%* %; \
    /endif

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;