X-Git-Url: https://jxself.org/git/?p=mudsync.git;a=blobdiff_plain;f=mudsync%2Froom.scm;h=d201c052a96cd8536e94f65b511af79966da0273;hp=6baea54ce99daef1d83e8b0440de2fb0ef8a4f5e;hb=5128272343835236d5e3410e12728cb2efe5a39f;hpb=29f902827724fd50b512c60916a16850367f6046 diff --git a/mudsync/room.scm b/mudsync/room.scm index 6baea54..d201c05 100644 --- a/mudsync/room.scm +++ b/mudsync/room.scm @@ -72,7 +72,8 @@ (empty-command "look" 'cmd-look-room) (empty-command "go" 'cmd-go-where) (loose-direct-command "go" 'cmd-go) - (greedy-command "say" 'cmd-say))) + (greedy-command "say" 'cmd-say) + (greedy-command "emote" 'cmd-emote))) (define room-actions (build-actions @@ -81,13 +82,15 @@ (wire-exits! (wrap-apply room-wire-exits!)) (cmd-go (wrap-apply room-cmd-go)) (cmd-go-where (wrap-apply room-cmd-go-where)) + (announce-entrance (wrap-apply room-announce-entrance)) (look-room (wrap-apply room-look-room)) (tell-room (wrap-apply room-act-tell-room)) ;; in this case the command is the same version as the normal ;; look-room version (cmd-look-room (wrap-apply room-look-room)) (cmd-look-at (wrap-apply room-look-at)) - (cmd-say (wrap-apply room-cmd-say)))) + (cmd-say (wrap-apply room-cmd-say)) + (cmd-emote (wrap-apply room-cmd-emote)))) (define room-actions* (append room-actions gameobj-actions)) @@ -134,11 +137,24 @@ claim to point to." (lambda (exit) (equal? (exit-name exit) direct-obj)) (room-exits room))) + (define to-address (if exit + (slot-ref exit 'to-address) + #f)) + (define player-name + (message-ref (<-wait room (message-from message) + 'get-name) 'val)) (cond (exit ;; Set the player's new location (<-wait room (message-from message) 'set-loc! - #:loc (slot-ref exit 'to-address)) + #:loc to-address) + ;; Tell everyone else the person walked away + (room-tell-room + room + (format #f "~a wanders ~a.\n" + player-name direct-obj)) + (<- room to-address 'announce-entrance + #:who-entered (message-from message)) ;; Have the new room update the player to the new location (<- room (slot-ref exit 'to-address) 'look-room #:to-id (message-from message))) @@ -235,7 +251,7 @@ claim to point to." #f))) (define %formless-desc - "You don't see anything special about it.") + "You don't see anything special.") (define-mhandler (room-look-at room message direct-obj) "Look at a specific object in the room." @@ -288,3 +304,21 @@ claim to point to." (define message-to-send (format #f "~a says: ~a\n" player-name phrase)) (room-tell-room room message-to-send)) + +(define-mhandler (room-cmd-emote room message phrase) + "Command: Say something to room participants." + (define player-name + (message-ref (<-wait room (message-from message) + 'get-name) 'val)) + (define message-to-send + (format #f "* ~a ~a\n" player-name phrase)) + (room-tell-room room message-to-send)) + +(define-mhandler (room-announce-entrance room message who-entered) + (define player-name + (message-ref (<-wait room who-entered 'get-name) + 'val)) + (define message-to-send + (format #f "~a enters the room.\n" player-name)) + (room-tell-room room message-to-send + #:exclude who-entered))