X Dressup!

How does that pesky dressing room work? It's all piled into a single spot script. Here's the version currently in use at The UnPalace. It has components in the ENTER, INCHAT, and OUTCHAT sections... see the notes after the code to enhance your understanding.

; In the ENTER section,
; we give each new entrant instructions, and reset the room if it was
; previously empty.


ON ENTER {
    ; Give each entrant instructions
    { "To dress someone, whisper \"dressup\"" STATUSMSG } 60 ALARMEXEC
    { "To avoid BEING dressed, say \"nodress\"" STATUSMSG } 120 ALARMEXEC
    { "To undo \"nodress,\" type \"redress\"" STATUSMSG } 180 ALARMEXEC
    {
	; special instructions for wizards
	{
	    "\"halt\" and \"resume\" for entire room" STATUSMSG
	} 220 ALARMEXEC
    } ISWIZARD IF
    {
	"Reminder: ALL BEDROOMS here have the dressup script," LOGMSG
	"just in case you want a lockable dressup room." LOGMSG
    } 250 ALARMEXEC
    ; reset the room
    {
	0 ME SETSPOTSTATE
	CLEARLOOSEPROPS
    } NBRROOMUSERS 1 == IF
}

; In the OUTCHAT block, we handle all user commands, including ones for the local wizard
; to halt the dressup code if things are getting out of hand.

ON OUTCHAT {
    nodressup GLOBAL
    ; Strip off any leading @ positions (spoofing)
    {
	"$1" GREPSUB cmd =
    } {
	CHATSTR cmd =
    } CHATSTR "^@[0-9]*,[0-9]* (.*)" GREPSTR IFELSE
    ; Turn off dressup for me only
    {
	1 nodressup =
	"No Dressup for You" STATUSMSG
	"" CHATSTR =
    } cmd "^nodress" GREPSTR IF
    ; Turn on dressup for me only
    {
	0 nodressup =
	"Now You Can Be Dressed" STATUSMSG
	"" CHATSTR =
    } cmd "^redress" GREPSTR IF
    ; Try to dressup your friend
    {
	{
	    NBRUSERPROPS n =
	    {
		0 i =
		";pp" 
		{
		    " " i USERPROP ITOA & &
		    i ++
		} { i n < } WHILE
	    WHOTARGET PRIVATEMSG
	    } n IF
	} {
	    "you have to whisper it" STATUSMSG
	} WHOTARGET IFELSE
	; Make sure it's mutual
	0 nodressup =
	"" CHATSTR =
    } cmd "dressup" == IF
    {
	NAKED
	"" CHATSTR =
    } cmd "^undress" GREPSTR IF
    ; repeat insructions
    {
	"To dress someone, whisper \"dressup\"" STATUSMSG
	{ "To avoid BEING dressed, say \"nodress\"" STATUSMSG } 60 ALARMEXEC
	{ "To undo \"nodress,\" type \"redress\"" STATUSMSG } 120 ALARMEXEC
	{ "Whisper to only be dressed by your friend" STATUSMSG } 180 ALARMEXEC
	{
	    {
		"\"halt\" and \"resume\" for entire room" STATUSMSG
	    } 220 ALARMEXEC
	} ISWIZARD IF
	"" CHATSTR =
    } cmd LOWERCASE "^help" GREPSTR IF
    ; Special wizard commands
    {
	1 ME SETSPOTSTATE
	"Dressups Halted" STATUSMSG
	"" CHATSTR =
    } ISWIZARD cmd "halt" == AND IF
    {
	0 ME SETSPOTSTATE
	"Dressups Resumed" STATUSMSG
	"" CHATSTR =
    } ISWIZARD cmd "resume" == AND IF
}

; The INCHAT block does the
; actual dressing.

ON INCHAT {
    nodressup GLOBAL
    ; Reset some rare crash conditions
    {
	0 ME SETSPOTSTATE
    } ME GETSPOTSTATE NBRROOMUSERS 2 < AND IF
    ; Dressup Receiver
    {
	{
	    "[ " "$1" GREPSUB & " ] SETPROPS" & STRTOATOM EXEC
	} {
	    "Sorry you can't dress me up" WHOCHAT PRIVATEMSG
	} nodressup NOT
	WHOTARGET NOT
	WHOTARGET WHOCHAT == OR AND
	ME GETSPOTSTATE NOT AND IFELSE
    } CHATSTR ";pp (-*[-0-9 ]*)$" GREPSTR
      WHOCHAT WHOME == NOT AND IF
}

Dressup is (IMHO) a good example of how to use several different tricks to achieve a single result. The less-than-obvious tricks it uses are:

Lots of alterations and improvements can be made to the dressup script, such as the variant you'll find in The UnPalace grab a friend and check out the "Masquerade" room.