home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume18 / dunnet2 / part02 / dun-batch.el < prev    next >
Lisp/Scheme  |  1993-07-12  |  2KB  |  85 lines

  1. ;;;;;;;;;;;;;;;;;;;
  2. ;;;;;;;;;;;;;;;;;;;
  3.  
  4.  
  5. ; These are functions, and function re-definitions so that dungeon can
  6. ; be run in batch mode.
  7.  
  8. (if nil
  9.     (eval-and-compile (setq byte-compile-warnings nil)))
  10.  
  11. (defun mprinc (arg)
  12.    (if (stringp arg)
  13.        (send-string-to-terminal arg)
  14.      (send-string-to-terminal (prin1-to-string arg))))
  15.  
  16. (defun mprincl (arg)
  17.    (if (stringp arg)
  18.        (progn
  19.            (send-string-to-terminal arg)
  20.            (send-string-to-terminal "\n"))
  21.      (send-string-to-terminal (prin1-to-string arg))
  22.      (send-string-to-terminal "\n")))
  23.  
  24. (defun parse (ignore verblist line)
  25.   (setq line-list (listify-string (concat line " ")))
  26.   (doverb ignore verblist (car line-list) (cdr line-list)))
  27.  
  28. (defun parse2 (ignore verblist line)
  29.   (setq line-list (listify-string2 (concat line " ")))
  30.   (doverb ignore verblist (car line-list) (cdr line-list)))
  31.  
  32. (defun read-line ()
  33.   (read-from-minibuffer "" nil dungeon-batch-map))
  34.  
  35. (setq batch-mode t)
  36.  
  37. (defun dungeon-batch-loop ()
  38.   (setq dead nil)
  39.   (setq room 0)
  40.   (while (not dead)
  41.     (if (eq dungeon-mode 'dungeon)
  42.     (progn
  43.       (if (not (= room current-room))
  44.           (progn
  45.         (describe-room current-room)
  46.         (setq room current-room)))
  47.       (mprinc ">")
  48.       (setq line (downcase (read-line)))
  49.       (if (eq (parse ignore verblist line) -1)
  50.           (mprinc "I don't understand that.\n"))))))
  51.  
  52. (defun dos-interface ()
  53.   (dos-boot-msg)
  54.   (setq dungeon-mode 'dos)
  55.   (while (eq dungeon-mode 'dos)
  56.     (dos-prompt)
  57.     (setq line (downcase (read-line)))
  58.     (if (eq (parse2 nil dos-verbs line) -1)
  59.     (progn
  60.       (sleep-for 1)
  61.       (mprincl "Bad command or file name"))))
  62.   (goto-char (point-max))
  63.   (mprinc "\n"))
  64.  
  65. (defun unix-interface ()
  66.     (login)
  67.     (if logged-in
  68.     (progn
  69.       (setq dungeon-mode 'unix)
  70.       (while (eq dungeon-mode 'unix)
  71.         (mprinc "$ ")
  72.         (setq line (downcase (read-line)))
  73.         (if (eq (parse2 nil unix-verbs line) -1)
  74.         (let (esign)
  75.           (if (setq esign (string-match "=" line))
  76.               (doassign line esign)        
  77.             (mprinc (car line-list))
  78.             (mprincl ": not found.")))))
  79.       (goto-char (point-max))
  80.       (mprinc "\n"))))
  81.  
  82. (defun dungeon-nil (arg)
  83.   "noop"
  84.   (interactive "*p"))
  85.