title: Call a function while in a loop (Common Lisp)
body: <p>I am making a console Lisp survival game and I am trying to add a function where until a = b, show "." every second. Then, when a = b, set a "hurt" variable to true, and if/when that variable is true, subtract "health" by 1 until the "use-medkit" function is invoked by the user and the "hurt" variable is set false and you exit both loops. </p>
  
  <p>The problem I am having is when I am prompted to use the "use-medkit" function and I type it in, it doesn't evaluate anything that I input and keeps subtracting 1 from "health". How can I call a user-inputted function while a loop is running?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>(setq a (random 11)) ; Random from 0 - 10
  (setq b (random 11)) ; ^^^^^^^^^^^^^^^^^^
  (setq hurt 0)
  (setq repair 0)
  (setq health 999)
  
  (defun use-medkit () 
      (setq repair 1))
  
  (defun get-hurt ()
      (loop
          (progn 
              (setq a (random 11))
              (setq b (random 11))
              (progn  
                  (princ ".")
                  (sleep 1)))
  
          (if (eq a b) (progn     
                          (setq hurt 1)
                          (when (eq hurt 1) (progn        
                                              (format t "~%You are hurt!~%You will lose 1 hp every 10 seconds~%~%Type use-medkit to stop the bleeding~%")
                                              (loop
                                                  (progn 
                                                      (- 1 health)
                                                      (sleep 10))
                                                      ;(format t "health: ~A~%" health)
                                                  (when (eq repair 1) (progn 
                                                                   (return "You stopped the bleeding") (setq hurt 0) (setq repair 0))))))))))
  </code></pre>