@q
@program Globals.muf
1 9999 d
i
( Globals.muf, by Ch'marr@FurryMUCK. Some parts by Jessy@FurryMUCK )

$include $lib/mucktools
$include $lib/strings
$include $lib/edit
  
lvar ourCounter
lvar ourDbref
lvar roomvalue
lvar imawiz
 
( if string1 is null, then return string2, otherwise return string1 )
: default ( string1 string2 -- string )
    swap dup if
        swap pop
    else
        pop
    then
;
 
: MatchMsg ( dbref -- 0 or dbref -- ref 1 )
   dup #-1 dbcmp if
      pop "I cant find that object" .tell 0
   else dup #-2 dbcmp if
      pop "I dont know which one you mean" .tell 0
   else dup #-3 dbcmp if
      pop "That's home!" .tell 0
   else dup #-4 dbcmp if
      pop "This program will work better if you specify something to modify." .tell 0
   else
      1
   then then then then
;
      
: DoHelp
    "Commands help (page 1 of 2)" .tell
    " " .tell
    "    This program will display a list of commands that are available to you" .tell
    "at any place you might be, whether they be attached to you, the room" .tell
    "you're currently in, or one of the parent rooms. Commands, or the" .tell
    "room (or player) they're attached to must be specifically configured" .tell
    "before they will be displayed by 'commands'. (see #help2)" .tell
    "    Actions on objects in the room with you are not displayed. Nor are" .tell
    "actions configured to display to Muck Wizards only (unless you're a wiz)." .tell
    "Commands are catagorised by where they are located, and the title names" .tell
    "may be changed to make more sense. By default, only the first alias of a" .tell
    "command is displayed, but this may be changed also." .tell
    "    Type 'commands #help2' for more options." .tell
    " " .tell
    "Commands. By Ch'marr@ForgottenPaths." .tell
    " " .tell
;
 
: DoHelp2
    "Commands help (page 2 of 2)" .tell
    " " .tell
    "commands                            - show available commands" .tell
    "commands #include              - include obj in listings" .tell
    "commands #exclude              - exclude obj in listings" .tell
    imawiz @ if 
        "commands #wizonly              - include obj only for wizzes" .tell
    then
    "commands #default              - return obj to default behaviour" .tell
    "   (For commands: value of room. For rooms: #exclude)" .tell
    "commands #title =      - change room title" .tell
    "commands #!title <room>             - return room title to default (room name)" .tell
    "commands #values <cmd>=<value>;...  - change command values (; separated list)" .tell
    "commands #!values <cmd>             - return command to default (first alias)" .tell
    " " .tell
    "<obj> is an exit,  room or 'me'." .tell
    "Type 'commands #help' for more help." .tell
;
 
: CheckAndMatch ( ref -- 0   OR  ref 1  )
    MatchMsg if
        dup owner imawiz @ or if
            1
        else
            pop "That's not yours!" .tell 0
        then
    else
        0
    then
;
 
: match2 ( string - ref )
    dup if
        match
    else
        pop #-4
    then
;
 
: DoInclude
    match2 CheckAndMatch if 
        "_commands/list" "yes" setprop
        ">> Included." .tell
    then
;
 
: DoExclude
    match2 CheckAndMatch if 
        "_commands/list" "no" setprop
        ">> Excluded." .tell
    then
;
 
: DoWizOnly
    match2 CheckAndMatch if 
        "_commands/list" "wizonly" setprop
        ">> Included." .tell
    then
;
 
: DoDefault
    match2 CheckAndMatch if 
        "_commands/list" remove_prop
        ">> Defaulted." .tell
    then
;
  
: DoValues
    "=" STRsplit swap
    match2 CheckAndMatch if 
        "_commands/values" rot setprop
        ">> Values set." .tell
    then
;
  
: DoNValues
    match2 CheckAndMatch if 
        "_commands/values" remove_prop
        ">> Values cleared." .tell
    then
;
  
: DoTitle
    "=" STRsplit swap
    match2 CheckAndMatch if 
        "_commands/title" rot setprop
        ">> Title set." .tell
    then
;
  
: DoNTitle
    match2 CheckAndMatch if 
        "_commands/title" remove_prop
        ">> Title cleared." .tell
    then
;
  
: DoCommands ( everything -- )
    
    pop
    me @ ourDbref !
    begin
        ourDbref @ while
        ourDbref @ exits ourCounter !
        ourDbref @ "_commands/list" getpropstr roomvalue !
        begin
            ourCounter @ while
            ourCounter @ "_commands/list" getpropstr roomvalue @ default
            dup "wizonly" stringcmp not if
                pop
                me @ "w" flag? if
                    ourCounter @ "_commands/values" getpropstr dup if
                        begin
                            dup while
                            ";" STRsplit swap
                            "(W)" strcat
                            swap
                        repeat
                        pop
                    else
                        pop
                        ourCounter @ name ";" STRsplit pop "(W)" strcat
                    then
                then
            else "yes" stringcmp not if
                ourCounter @ "_commands/values" getpropstr dup if
                    begin
                        dup while
                        ";" STRsplit swap
                        swap
                    repeat
                    pop
                else
                    pop
                    ourCounter @ name ";" STRsplit pop
                then
            then then
            ourCounter @ next ourCounter !
        repeat
        depth if
            ourDbref @ "_commands/title" getpropstr dup not if
                pop
                ourDbref @ name " Commands:" strcat .tell " " .tell
            else
                .tell " " .tell
            then
            depth 0 0 EDITsort 3-col " " .tell
        then
        ourDbref @ location ourDbref !
    repeat
    "Note: This program lists only soft-coded commands. There are also "
    "numerous server commands available." strcat .tell
;
 
: main
    "me" match me !
    me @ "w" flag? imawiz !
    dup if
        " " STRsplit swap
        dup "#help" stringcmp not if pop DoHelp else
        dup "#help2" stringcmp not if pop DoHelp2 else
        dup "#include" stringcmp not if pop DoInclude else
        dup "#exclude" stringcmp not if pop DoExclude else
        dup "#wizonly" stringcmp not imawiz @ and if pop DoWizOnly else
        dup "#default" stringcmp not if pop DoDefault else
        dup "#values" stringcmp not if pop DoValues else
        dup "#!values" stringcmp not if pop DoNValues else
        dup "#title" stringcmp not if pop DoTitle else
        dup "#!title" stringcmp not if pop DoNTitle else
            pop
            "I have no idea what you mean. try 'commands #help'" .tell
        then then then then then then then then then then
    else
        DoCommands
    then
;
.
c
q



	  </pre>
	</body>
</html>