ask for the name at startup
1 files changed, 24 insertions(+), 6 deletions(-)

M dryads-wake.w
M dryads-wake.w +24 -6
@@ 26,6 26,7 @@ import
     only (ice-9 format) format
     only (srfi srfi-1) first second third alist-cons assoc lset<= lset-intersection lset-difference remove
     only (ice-9 ftw) scandir
+    only (ice-9 rdelim) read-line
     enter
     only (d6) roll check
     doctests

          
@@ 1038,17 1039,28 @@ define : game-state-key
         if key
             cdr key
             . #f
+define : game-state-name
+    let : : name : assoc 'name : game-state
+        if name
+            cdr name
+            . #f
+define : game-state-key-set! key
+    set! %game-state : alist-cons 'key key : game-state
+define : game-state-name-set! name
+    set! %game-state : alist-cons 'name name : game-state
+define : name->key name
+    string-downcase
+        string-filter char-set:ascii name
 define : game-state-init!
     set! *random-state*
         random-state-from-platform
     set! %game-state
         alist-cons 'key
-            string-downcase
-                string-filter char-set:ascii
-                    string-append
-                        list-ref first-names : random : length first-names
-                        . "-"
-                        list-ref last-names : random : length last-names
+            name->key
+                string-append
+                    list-ref first-names : random : length first-names
+                    . "-"
+                    list-ref last-names : random : length last-names
             game-state
 
 define %data-folder

          
@@ 1209,9 1221,15 @@ define : first-encounter
             Melter Lark :profile melter
             Rooted Breeze :profile dryad
     
+    Print
+        Please choose your name
     game-state-init!
+    game-state-name-set! : read-line
+    game-state-key-set! : name->key : game-state-name
     game-state-scene-set! first-encounter
     save-state : game-state-key
+    Print
+        Welcome ,(game-state-name)!
 
     Juli Fin
         Finally we have our own home!