( NewWho.MUF - v1.0a - by Ginger@FurToonia ) ( ) ( Another magic GingerClone[tm], this one lists who is, and is not awake ) ( in the room you're in [standard] but allows wizards and room owners to ) ( see into remote rooms and/or change the format of the messages. ) ( Players can also display an [Away] or [Busy] flag after their names or ) ( create a custom flag of no more than four letters. ) ( All formatting properties can take MPI. The program searches down the ) ( environment tree for each property. ) ( Thank you Fringe for designing $lib/case! ) $define case begin dup $enddef $define when if pop $enddef $define end break then dup $enddef $define default pop 1 if $enddef $define endcase pop pop 1 until $enddef lvar count lvar room lvar arg lvar current lvar tag lvar on? lvar acount lvar scount lvar mcount lvar icount lvar awake lvar asleep lvar muppets lvar idle lvar awakefmt lvar asleepfmt lvar muppetfmt lvar idlefmt lvar alonefmt lvar nosleepfmt lvar env : get_mesgs "&" awakefmt ! "&" asleepfmt ! "&" muppetfmt ! "&" alonefmt ! "&" nosleepfmt ! "&" idlefmt ! room @ begin dup #-1 dbcmp not while env ! env @ "who/awake" "(@PROG}" 1 parseprop dup "" stringcmp 0 = if pop else awakefmt @ "&" stringcmp 0 = if awakefmt ! else pop then then env @ "who/asleep" "(@PROG)" 1 parseprop dup "" stringcmp 0 = if pop else asleepfmt @ "&" stringcmp 0 = if asleepfmt ! else pop then then env @ "who/puppet" "(@PROG)" 1 parseprop dup "" stringcmp 0 = if pop else muppetfmt @ "&" stringcmp 0 = if muppetfmt ! else pop then then env @ "who/alone" "(@PROG)" 1 parseprop dup "" stringcmp 0 = if pop else alonefmt @ "&" stringcmp 0 = if alonefmt ! else pop then then env @ "who/nosleep" "(@PROG)" 1 parseprop dup "" stringcmp 0 = if pop else nosleepfmt @ "&" stringcmp 0 = if nosleepfmt ! else pop then then env @ "who/idle" "(@PROG)" 1 parseprop dup "" stringcmp 0 = if pop else idlefmt @ "&" stringcmp 0 = if idlefmt ! else pop then then env @ location repeat awakefmt @ "&" stringcmp 0 = if "The players awake %there are: %m" awakefmt ! then asleepfmt @ "&" stringcmp 0 = if "%m %isare asleep %there." asleepfmt ! then muppetfmt @ "&" stringcmp 0 = if "The puppets %there are: %m" muppetfmt ! then idlefmt @ "&" stringcmp 0 = if "%m %isare out of it %there." idlefmt ! then ; : show_room get_mesgs acount @ case 0 = alonefmt @ "&" stringcmp 0 = me @ location room @ dbcmp and and when "You are the only one awake here." .tell end 0 = alonefmt @ "&" stringcmp 0 = not me @ location room @ dbcmp and and when alonefmt @ .tell end 0 = me @ location room @ dbcmp not and when "There is no-one awake there." .tell end default awakefmt @ awake @ "%m" subst acount @ intostr "%num" subst me @ location room @ dbcmp if "here" else "there" then "%there" subst acount @ 1 = if "is" else "are" then "%isare" subst room @ name "%here" subst .tell end endcase icount @ case 0 = when " " pop end 1 >= when idlefmt @ idle @ "%m" subst icount @ intostr "%num" subst me @ location room @ dbcmp if "here" else "there" then "%there" subst icount @ 1 = if "is" else "are" then "%isare" subst room @ name "%here" subst .tell end endcase scount @ case 0 = nosleepfmt @ "&" stringcmp 0 = me @ location room @ dbcmp and and when "There are no sleepers here." .tell end 0 = nosleepfmt @ "&" stringcmp 0 = and when "There are no sleepers there." .tell end 0 = nosleepfmt @ "&" stringcmp 0 = not and when nosleepfmt @ .tell end 1 >= when asleepfmt @ asleep @ "%m" subst scount @ intostr "%num" subst me @ location room @ dbcmp if "here" else "there" then "%there" subst scount @ 1 = if "is" else "are" then "%isare" subst room @ name "%here" subst room @ "D" flag? if pop else .tell then end endcase mcount @ case 0 = when " " pop end 1 >= when muppetfmt @ muppets @ "%m" subst mcount @ intostr "%num" subst me @ location room @ dbcmp if "here" else "there" then "%there" subst mcount @ 1 = if "is" else "are" then "%isare" subst room @ name "%here" subst room @ "D" flag? if pop else .tell then end endcase ; : idle? current @ descriptors begin dup 1 = not while dup rotate pop 1 - repeat pop descrcon conidle dup 180 < if pop 0 else pop 1 then ; : getidle ( d -- s ) current @ descriptors begin dup 1 = not while dup rotate pop 1 - REPEAT pop descrcon conidle dup 3600 > if 3600 "h" else 60 "m" then rot rot / intostr swap strcat ; : get_lists room @ "who/noshow" "(@PROG)" 1 parseprop dup "" stringcmp 0 = not if "WHO: " swap strcat .tell exit then room @ contents current ! begin current @ #-1 dbcmp not while current @ player? current @ dup thing? swap "Z" flag? and or not if current @ next current ! continue then count @ 1 + count ! current @ me @ dbcmp if current @ next current ! continue then current @ thing? if current @ name "(" current @ owner name "), " strcat strcat strcat mcount @ 1 + mcount ! muppets @ swap strcat muppets ! current @ next current ! continue then current @ player? current @ awake? not and if current @ name ", " strcat asleep @ swap strcat asleep ! scount @ 1 + scount ! current @ next current ! continue then current @ idle? if current @ name "(" getidle "), " strcat strcat strcat idle @ swap strcat idle ! icount @ 1 + icount ! current @ next current ! continue then acount @ 1 + acount ! current @ name current @ "_prefs/who/flag" getpropstr dup "" stringcmp 0 = if pop "" else dup "[" stringpfx 1 = not if " " strcat 4 strcut pop "[" swap strcat "]" strcat strcat then then strcat ", " strcat awake @ swap strcat awake ! current @ next current ! continue repeat acount @ 2 >= if awake @ strip dup " " rinstr 2 - strcut 2 strcut swap pop " and " swap strcat strcat awake ! then scount @ 2 >= if asleep @ strip dup " " rinstr 2 - strcut 2 strcut swap pop " and " swap strcat strcat asleep ! then mcount @ 2 >= if muppets @ strip dup " " rinstr 2 - strcut 2 strcut swap pop " and " swap strcat strcat muppets ! then icount @ 2 >= if idle @ strip dup " " rinstr 2 - strcut 2 strcut swap pop " and " swap strcat strcat idle ! then acount @ 0 = if "not a problem" awake ! then scount @ 0 = if "not a problem" asleep ! then mcount @ 0 = if "not a problem" muppets ! then icount @ 0 = if "not a problem" idle ! then awake @ strip dup strlen 1 - strcut pop awake ! asleep @ strip dup strlen 1 - strcut pop asleep ! muppets @ strip dup strlen 1 - strcut pop muppets ! idle @ strip dup strlen 1 - strcut pop idle ! show_room ; : set_room arg @ "#" stringpfx 0 = if me @ location room ! get_lists exit then arg @ 1 strcut swap pop atoi dbref room ! me @ "W" flag? room @ owner me @ dbcmp or not if me @ location room ! get_lists exit then room @ room? not if "That isn't a room." .tell exit then get_lists ; : toggle_flag on? @ if me @ "_prefs/who/flag" tag @ 1 addprop "Flag set to " tag @ "." strcat strcat .tell else me @ "_prefs/who/flag" remove_prop "Flag removed." .tell then ; : help "NewWho.MUF - v1.0a - Ginger@FurToonia" .tell " " .tell "who Lists who is awake/asleep/a puppet in this room" .tell "who #1234 Lists 'who' in room #1234, if you own it" .tell "who #away Sets your flag in the 'who' listing to [Away]" .tell "who #busy Sets your flag to [Busy]" .tell "who #custom Sets your flag to , up to 4 characters" .tell "who #! Clears any flag" .tell "who #help This screen" .tell "who #help2 More help on setting up custom room formats" .tell " " .tell "Commands can be shortened to the first letter or so." .tell "If the room is set D, only awake and idle characters are listed." .tell ; : help2 "NewWho.MUF - v1.0a - Ginger@FurToonia" .tell " " .tell "You can customise who listings for rooms you own by setting the following" .tell "properties on the room itself or on an environment room:" .tell " " .tell "Property Default" .tell "-------- -------" .tell "who/awake The players awake here are: %m" .tell "who/asleep %m %isare asleep here." .tell "who/puppet The puppets here are: %m" .tell "who/idle %m %isare out of it here." .tell "who/alone You are the only one awake here." .tell "who/nosleep There are no sleepers here." .tell "who/noshow It's too dark to see in here." .tell " " .tell "%m in a mesg returns the appropriate list of players. %here returns the" .tell "room name. %isare returns 'is' or 'are' as appropriate. %num returns the" .tell "number of players awake, etc. alone, nosleep and noshow don't take subs." .tell "If who/noshow is set, 'who' will not work in that room, and will give the" .tell "value of the prop as the error message. All props take MPI." .tell ; : main 0 count ! 0 acount ! 0 scount ! 0 mcount ! 0 icount ! "" awake ! "" muppets ! "" asleep ! "" idle ! dup "" stringcmp 0 = if pop " " arg ! else strip arg ! then arg @ case " " stringcmp 0 = when me @ location room ! get_lists exit end "#a" stringpfx 1 = when "[Away]" tag ! 1 on? ! toggle_flag exit end "#!" stringpfx 1 = when 0 on? ! toggle_flag exit end "#b" stringpfx 1 = when "[Busy]" tag ! 1 on? ! toggle_flag exit end dup "#c" stringpfx 1 = when 1 on? ! dup " " instr strcut swap pop " " strcat 4 strcut pop "[" swap "]" strcat strcat tag ! toggle_flag exit end dup "#help" stringcmp 0 = swap "#h" stringcmp 0 = or when help exit end dup "#help2" stringcmp 0 = swap "#h2" stringcmp 0 = or when help2 exit end dup "#" stringpfx 1 = swap 1 strcut swap pop number? and when set_room exit end default me @ location room ! get_lists exit end endcase ;