some improvements to asking about things
[mudsync.git] / worlds / bricabrac.scm
index e5392aaa428222699a8012e7046e48c76545d20a..3ce948d4b7fe568b097f9e0a3a18d4612eedbdf0 100644 (file)
@@ -20,7 +20,7 @@
 
 (use-modules (mudsync)
              (mudsync parser)
 
 (use-modules (mudsync)
              (mudsync parser)
-             (8sync systems actors)
+             (8sync actors)
              (8sync agenda)
              (oop goops)
              (ice-9 control)
              (8sync agenda)
              (oop goops)
              (ice-9 control)
   (commands
    #:init-value readable-commands*)
   (actions #:allocation #:each-subclass
   (commands
    #:init-value readable-commands*)
   (actions #:allocation #:each-subclass
-           #:init-value (mhandlers
+           #:init-value (build-actions
                          (cmd-read readable-cmd-read))))
 
 (define (readable-cmd-read actor message)
                          (cmd-read readable-cmd-read))))
 
 (define (readable-cmd-read actor message)
-  (<- actor (message-from message) 'tell
+  (<- (message-from message) 'tell
       #:text (string-append (slot-ref actor 'read-text) "\n")))
 
 
       #:text (string-append (slot-ref actor 'read-text) "\n")))
 
 
@@ -77,7 +77,7 @@
     (format #f "~a says: \"~a\"\n"
             (slot-ref actor 'name)
             (random-choice (slot-ref actor 'catchphrases))))
     (format #f "~a says: \"~a\"\n"
             (slot-ref actor 'name)
             (random-choice (slot-ref actor 'catchphrases))))
-  (<- actor (message-from message) 'tell
+  (<- (message-from message) 'tell
       #:text text-to-send))
 
 (define chat-commands
       #:text text-to-send))
 
 (define chat-commands
@@ -108,7 +108,7 @@ or 'skribe'?  Now *that's* composition!"))
    #:init-value chat-commands)
   (actions #:allocation #:each-subclass
            #:init-value
    #:init-value chat-commands)
   (actions #:allocation #:each-subclass
            #:init-value
-           (mhandlers
+           (build-actions
             (cmd-chat npc-chat-randomly))))
 
 (define random-bricabrac
             (cmd-chat npc-chat-randomly))))
 
 (define random-bricabrac
@@ -128,7 +128,7 @@ or 'skribe'?  Now *that's* composition!"))
     (prep-direct-command "sign" 'cmd-sign-form
                          '("as"))))
   (actions #:allocation #:each-subclass
     (prep-direct-command "sign" 'cmd-sign-form
                          '("as"))))
   (actions #:allocation #:each-subclass
-           #:init-value (mhandlers
+           #:init-value (build-actions
                          (cmd-sign-form sign-cmd-sign-in))))
 
 
                          (cmd-sign-form sign-cmd-sign-in))))
 
 
@@ -146,15 +146,15 @@ or 'skribe'?  Now *that's* composition!"))
 (define* (sign-cmd-sign-in actor message
                            #:key direct-obj indir-obj preposition)
   (define old-name
 (define* (sign-cmd-sign-in actor message
                            #:key direct-obj indir-obj preposition)
   (define old-name
-    (msg-val (<-wait actor (message-from message) 'get-name)))
+    (mbody-val (<-wait (message-from message) 'get-name)))
   (define name indir-obj)
   (if (valid-name? indir-obj)
       (begin
   (define name indir-obj)
   (if (valid-name? indir-obj)
       (begin
-        (<-wait actor (message-from message) 'set-name! name)
-        (<- actor (slot-ref actor 'loc) 'tell-room
+        (<-wait (message-from message) 'set-name! name)
+        (<- (slot-ref actor 'loc) 'tell-room
             #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
                            old-name old-name name)))
             #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
                            old-name old-name name)))
-      (<- actor (message-from message) 'tell
+      (<- (message-from message) 'tell
           #:text "Sorry, that's not a valid name.
 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
 character.\n")))
           #:text "Sorry, that's not a valid name.
 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
 character.\n")))
@@ -173,7 +173,7 @@ character.\n")))
   (commands
    #:init-value summoning-bell-commands*)
   (actions #:allocation #:each-subclass
   (commands
    #:init-value summoning-bell-commands*)
   (actions #:allocation #:each-subclass
-           #:init-value (mhandlers
+           #:init-value (build-actions
                          (cmd-ring summoning-bell-cmd-ring))))
 
 (define* (summoning-bell-cmd-ring bell message . _)
                          (cmd-ring summoning-bell-cmd-ring))))
 
 (define* (summoning-bell-cmd-ring bell message . _)
@@ -182,13 +182,13 @@ character.\n")))
   ;; handler... meanwhile, this procedure suspends until we get
   ;; their response.
   (define who-rang
   ;; handler... meanwhile, this procedure suspends until we get
   ;; their response.
   (define who-rang
-    (msg-val (<-wait bell (message-from message) 'get-name)))
+    (mbody-val (<-wait (message-from message) 'get-name)))
 
   ;; Now we'll invoke the "tell" message handler on the player
   ;; who rang us, displaying this text on their screen.
   ;; This one just uses <- instead of <-wait, since we don't
   ;; care when it's delivered; we're not following up on it.
 
   ;; Now we'll invoke the "tell" message handler on the player
   ;; who rang us, displaying this text on their screen.
   ;; This one just uses <- instead of <-wait, since we don't
   ;; care when it's delivered; we're not following up on it.
-  (<- bell (message-from message) 'tell
+  (<- (message-from message) 'tell
       #:text "*ring ring!*  You ring the bell!\n")
   ;; We also want everyone else in the room to "hear" the bell,
   ;; but they get a different message since they aren't the ones
       #:text "*ring ring!*  You ring the bell!\n")
   ;; We also want everyone else in the room to "hear" the bell,
   ;; but they get a different message since they aren't the ones
@@ -196,7 +196,7 @@ character.\n")))
   ;; name as extracted and assigned to the who-rang variable.
   ;; Notice how we send this message to our "location", which
   ;; forwards it to the rest of the occupants in the room.
   ;; name as extracted and assigned to the who-rang variable.
   ;; Notice how we send this message to our "location", which
   ;; forwards it to the rest of the occupants in the room.
-  (<- bell (gameobj-loc bell) 'tell-room
+  (<- (gameobj-loc bell) 'tell-room
       #:text
       (format #f "*ring ring!*  ~a rings the bell!\n"
               who-rang)
       #:text
       (format #f "*ring ring!*  ~a rings the bell!\n"
               who-rang)
@@ -204,7 +204,7 @@ character.\n")))
   ;; Now we perform the primary task of the bell, which is to summon
   ;; the "clerk" character to the room.  (This is configurable,
   ;; so we dynamically look up their address.)
   ;; Now we perform the primary task of the bell, which is to summon
   ;; the "clerk" character to the room.  (This is configurable,
   ;; so we dynamically look up their address.)
-  (<- bell (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
+  (<- (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
       #:who-summoned (message-from message)))
 
 
       #:who-summoned (message-from message)))
 
 
@@ -223,7 +223,7 @@ character.\n")))
     #:desc
     "  You're in some sort of hotel lobby.  You see a large sign hanging
 over the desk that says \"Hotel Bricabrac\".  On the desk is a bell
     #:desc
     "  You're in some sort of hotel lobby.  You see a large sign hanging
 over the desk that says \"Hotel Bricabrac\".  On the desk is a bell
-that says \"ring for service\".  Terrible music plays from a speaker
+that says \"'ring bell' for service\".  Terrible music plays from a speaker
 somewhere overhead.
   The room is lined with various curio cabinets, filled with all sorts
 of kitschy junk.  It looks like whoever decorated this place had great
 somewhere overhead.
   The room is lined with various curio cabinets, filled with all sorts
 of kitschy junk.  It looks like whoever decorated this place had great
@@ -385,17 +385,17 @@ if this room is intended for children or child-like adults."
    (list
     (direct-command "sit" 'cmd-sit-furniture)))
   (actions #:allocation #:each-subclass
    (list
     (direct-command "sit" 'cmd-sit-furniture)))
   (actions #:allocation #:each-subclass
-           #:init-value (mhandlers
+           #:init-value (build-actions
                          (cmd-sit-furniture furniture-cmd-sit))))
 
 (define* (furniture-cmd-sit actor message #:key direct-obj)
   (define player-name
                          (cmd-sit-furniture furniture-cmd-sit))))
 
 (define* (furniture-cmd-sit actor message #:key direct-obj)
   (define player-name
-    (msg-val (<-wait actor (message-from message) 'get-name)))
-  (<- actor (message-from message) 'tell
+    (mbody-val (<-wait (message-from message) 'get-name)))
+  (<- (message-from message) 'tell
       #:text (format #f "You ~a ~a.\n"
                      (slot-ref actor 'sit-phrase)
                      (slot-ref actor 'sit-name)))
       #:text (format #f "You ~a ~a.\n"
                      (slot-ref actor 'sit-phrase)
                      (slot-ref actor 'sit-name)))
-  (<- actor (slot-ref actor 'loc) 'tell-room
+  (<- (slot-ref actor 'loc) 'tell-room
       #:text (format #f "~a ~a on ~a.\n"
                      player-name
                      (slot-ref actor 'sit-phrase-third-person)
       #:text (format #f "~a ~a on ~a.\n"
                      player-name
                      (slot-ref actor 'sit-phrase-third-person)
@@ -484,7 +484,7 @@ seat in the room, though."
   (commands #:init-value clerk-commands*)
   (patience #:init-value 0)
   (actions #:allocation #:each-subclass
   (commands #:init-value clerk-commands*)
   (patience #:init-value 0)
   (actions #:allocation #:each-subclass
-           #:init-value (mhandlers
+           #:init-value (build-actions
                          (init clerk-act-init)
                          (cmd-chat clerk-cmd-chat)
                          (cmd-ask-incomplete clerk-cmd-ask-incomplete)
                          (init clerk-act-init)
                          (cmd-chat clerk-cmd-chat)
                          (cmd-ask-incomplete clerk-cmd-ask-incomplete)
@@ -497,7 +497,7 @@ seat in the room, though."
   ;; call the gameobj main init method
   (gameobj-act-init clerk message)
   ;; start our main loop
   ;; call the gameobj main init method
   (gameobj-act-init clerk message)
   ;; start our main loop
-  (<- clerk (actor-id clerk) 'update-loop))
+  (<- (actor-id clerk) 'update-loop))
 
 (define clerk-help-topics
   '(("changing name" .
 
 (define clerk-help-topics
   '(("changing name" .
@@ -518,7 +518,7 @@ feel free to walk around and explore.")))
 
 
 (define clerk-knows-about
 
 
 (define clerk-knows-about
-  "'changing name', 'common commands', and 'about the hotel'")
+  "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
 
 (define clerk-general-helpful-line
   (string-append
 
 (define clerk-general-helpful-line
   (string-append
@@ -538,56 +538,57 @@ with tuition at where it is..."))
 (define* (clerk-cmd-chat clerk message #:key direct-obj)
   (match (slot-ref clerk 'state)
     ('on-duty
 (define* (clerk-cmd-chat clerk message #:key direct-obj)
   (match (slot-ref clerk 'state)
     ('on-duty
-     (<- clerk (message-from message) 'tell
+     (<- (message-from message) 'tell
          #:text clerk-general-helpful-line))
     ('slacking
          #:text clerk-general-helpful-line))
     ('slacking
-     (<- clerk (message-from message) 'tell
+     (<- (message-from message) 'tell
          #:text
          (string-append
           "The clerk says, \""
           (random-choice clerk-slacking-complaints)
           "\"\n")))))
 
          #:text
          (string-append
           "The clerk says, \""
           (random-choice clerk-slacking-complaints)
           "\"\n")))))
 
-(define (clerk-cmd-ask-incomplete clerk message)
-  (<- clerk (message-from message) 'tell
+(define (clerk-cmd-ask-incomplete clerk message . _)
+  (<- (message-from message) 'tell
       #:text "The clerk says, \"Ask about what?\"\n"))
 
 (define clerk-doesnt-know-text
   "The clerk apologizes and says she doesn't know about that topic.\n")
 
       #:text "The clerk says, \"Ask about what?\"\n"))
 
 (define clerk-doesnt-know-text
   "The clerk apologizes and says she doesn't know about that topic.\n")
 
-(define (clerk-cmd-ask clerk message indir-obj)
+(define* (clerk-cmd-ask clerk message #:key indir-obj
+                        #:allow-other-keys)
   (match (slot-ref clerk 'state)
     ('on-duty
      (match (assoc (pk 'indir indir-obj) clerk-help-topics)
        ((_ . info)
   (match (slot-ref clerk 'state)
     ('on-duty
      (match (assoc (pk 'indir indir-obj) clerk-help-topics)
        ((_ . info)
-           (<- clerk (message-from message) 'tell
+           (<- (message-from message) 'tell
                #:text
                (string-append "The clerk clears her throat and says:\n  \""
                               info
                               "\"\n")))
        (#f
                #:text
                (string-append "The clerk clears her throat and says:\n  \""
                               info
                               "\"\n")))
        (#f
-        (<- clerk (message-from message) 'tell
+        (<- (message-from message) 'tell
             #:text clerk-doesnt-know-text))))
     ('slacking
             #:text clerk-doesnt-know-text))))
     ('slacking
-     (<- clerk (message-from message) 'tell
+     (<- (message-from message) 'tell
          #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
 
 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
   (match (slot-ref clerk 'state)
     ('on-duty
          #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
 
 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
   (match (slot-ref clerk 'state)
     ('on-duty
-     (<- clerk who-summoned 'tell
+     (<- who-summoned 'tell
          #:text
          "The clerk tells you as politely as she can that she's already here,
 so there's no need to ring the bell.\n"))
     ('slacking
          #:text
          "The clerk tells you as politely as she can that she's already here,
 so there's no need to ring the bell.\n"))
     ('slacking
-     (<- clerk (gameobj-loc clerk) 'tell-room
+     (<- (gameobj-loc clerk) 'tell-room
          #:text
          "The clerk's ears perk up, she stamps out a cigarette, and she
 runs out of the room!\n")
      (gameobj-set-loc! clerk (dyn-ref clerk 'room:lobby))
      (slot-set! clerk 'patience 8)
      (slot-set! clerk 'state 'on-duty)
          #:text
          "The clerk's ears perk up, she stamps out a cigarette, and she
 runs out of the room!\n")
      (gameobj-set-loc! clerk (dyn-ref clerk 'room:lobby))
      (slot-set! clerk 'patience 8)
      (slot-set! clerk 'state 'on-duty)
-     (<- clerk (gameobj-loc clerk) 'tell-room
+     (<- (gameobj-loc clerk) 'tell-room
          #:text
          (string-append
           "  Suddenly, a uniformed woman rushes into the room!  She's wearing a
          #:text
          (string-append
           "  Suddenly, a uniformed woman rushes into the room!  She's wearing a
@@ -600,10 +601,10 @@ You can ask me about the following:
 
 (define* (clerk-cmd-dismiss clerk message . _)
   (define player-name
 
 (define* (clerk-cmd-dismiss clerk message . _)
   (define player-name
-    (msg-val (<-wait clerk (message-from message) 'get-name)))
+    (mbody-val (<-wait (message-from message) 'get-name)))
   (match (slot-ref clerk 'state)
     ('on-duty
   (match (slot-ref clerk 'state)
     ('on-duty
-     (<- clerk (gameobj-loc clerk) 'tell-room
+     (<- (gameobj-loc clerk) 'tell-room
          #:text
          (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
 The clerk leaves the room in a hurry.\n"
          #:text
          (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
 The clerk leaves the room in a hurry.\n"
@@ -611,11 +612,11 @@ The clerk leaves the room in a hurry.\n"
          #:exclude (actor-id clerk))
      (gameobj-set-loc! clerk (dyn-ref clerk 'room:break-room))
      (slot-set! clerk 'state 'slacking)
          #:exclude (actor-id clerk))
      (gameobj-set-loc! clerk (dyn-ref clerk 'room:break-room))
      (slot-set! clerk 'state 'slacking)
-     (<- clerk (gameobj-loc clerk) 'tell-room
+     (<- (gameobj-loc clerk) 'tell-room
          #:text clerk-return-to-slacking-text
          #:exclude (actor-id clerk)))
     ('slacking
          #:text clerk-return-to-slacking-text
          #:exclude (actor-id clerk)))
     ('slacking
-     (<- clerk (message-from message) 'tell
+     (<- (message-from message) 'tell
          #:text "The clerk sternly asks you to not be so dismissive.\n"))))
 
 (define clerk-slacking-texts
          #:text "The clerk sternly asks you to not be so dismissive.\n"))))
 
 (define clerk-slacking-texts
@@ -634,7 +635,9 @@ The clerk leaves the room in a hurry.\n"
     "The clerk takes a deep breath.\n"
     "The clerk yawns.\n"
     "The clerk drums her nails on the counter.\n"
     "The clerk takes a deep breath.\n"
     "The clerk yawns.\n"
     "The clerk drums her nails on the counter.\n"
-    "The clerk clicks around on the desk computer.\n"))
+    "The clerk clicks around on the desk computer.\n"
+    "The clerk thumbs through a printout of some physics paper.\n"
+    "The clerk mutters that her dissertation isn't going to write itself.\n"))
 
 (define clerk-slack-excuse-text
   "The desk clerk excuses herself, claiming she has important things to
 
 (define clerk-slack-excuse-text
   "The desk clerk excuses herself, claiming she has important things to
@@ -646,7 +649,7 @@ attend to.\n")
 
 (define (clerk-act-update-loop clerk message)
   (define (tell-room text)
 
 (define (clerk-act-update-loop clerk message)
   (define (tell-room text)
-    (<- clerk (gameobj-loc clerk) 'tell-room
+    (<- (gameobj-loc clerk) 'tell-room
         #:text text
         #:exclude (actor-id clerk)))
   (define (loop-if-not-destructed)
         #:text text
         #:exclude (actor-id clerk)))
   (define (loop-if-not-destructed)
@@ -659,7 +662,7 @@ attend to.\n")
         ;; route: it's much more live hackable.  If we change the definition
         ;; of this method, the character will act differently on the next
         ;; "tick" of the loop.
         ;; route: it's much more live hackable.  If we change the definition
         ;; of this method, the character will act differently on the next
         ;; "tick" of the loop.
-        (<- clerk (actor-id clerk) 'update-loop)))
+        (<- (actor-id clerk) 'update-loop)))
   (match (slot-ref clerk 'state)
     ('slacking
      (tell-room (random-choice clerk-slacking-texts))
   (match (slot-ref clerk 'state)
     ('slacking
      (tell-room (random-choice clerk-slacking-texts))