From: Christopher Allan Webber Date: Fri, 6 May 2016 15:29:26 +0000 (-0500) Subject: ability to say things, at last! X-Git-Tag: fosdem-2017~167 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=b8279be0a2ca8f5e235166acd5cc1bde3854dd5b;p=mudsync.git ability to say things, at last! --- diff --git a/mudsync/parser.scm b/mudsync/parser.scm index e9c4096..5da6bc9 100644 --- a/mudsync/parser.scm +++ b/mudsync/parser.scm @@ -100,7 +100,7 @@ (#f #f))) (define (cmatch-greedy phrase) - `((line . ,phrase))) + `(#:phrase ,phrase)) ;; (define say-example "say I really need to get going.") ;; (define attack-sword-example "hit goblin with sword") diff --git a/mudsync/room.scm b/mudsync/room.scm index 0b0e101..b665a15 100644 --- a/mudsync/room.scm +++ b/mudsync/room.scm @@ -72,8 +72,7 @@ (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))) (define room-actions (build-actions @@ -83,11 +82,12 @@ (cmd-go (wrap-apply room-cmd-go)) (cmd-go-where (wrap-apply room-cmd-go-where)) (look-room (wrap-apply room-look-room)) - (tell-room (wrap-apply room-tell-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-look-at (wrap-apply room-look-at)) + (cmd-say (wrap-apply room-cmd-say)))) (define room-actions* (append room-actions gameobj-actions)) @@ -259,18 +259,33 @@ claim to point to." (<- room (message-from message) 'tell #:text "You don't see that here, so you can't look at it.\n")))) -(define-mhandler (room-tell-room room message text) - "Tell the room some messages." - (define exclude (message-ref message 'exclude #f)) - (define wait-delivery (message-ref message 'wait-delivery #f)) + +(define* (room-tell-room room text #:key exclude wait) (define who-to-tell (gameobj-occupants room #:exclude exclude)) (for-each (lambda (tell-me) ;; @@: Does anything really care? (define deliver-method - (if wait-delivery + (if wait <-wait <-)) (deliver-method room tell-me 'tell #:text text)) who-to-tell)) + +(define-mhandler (room-act-tell-room room message text) + "Tell the room some messages." + (define exclude (message-ref message 'exclude #f)) + (define wait-delivery (message-ref message 'wait #f)) + (room-tell-room room text + #:exclude exclude + #:wait wait-delivery)) + +(define-mhandler (room-cmd-say 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 says: ~a\n" player-name phrase)) + (room-tell-room room message-to-send))