diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 0bbe63b..e22c126 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -67,12 +67,24 @@ ((equalp choice 'e) (format t "~&Goodbye!") (quit)))) -;; TODO -;; (defun parse-commandline-args () -;; (do* ((i 0 (1+ i)) (a (nth i *args*) (nth i *args)) -;; (param-functions '(("--version" (#'print-version 0)) -;; ("--help" (#'print-help 0)) -;; ("--server" +(defun cmd-parameter (name &optional truth-value) + "Return the value of the parameter 'name'. Or T for present if truth-value." + (let ((argument (member name *args* :test #'equalp))) + (if argument + (if truth-value T + (second argument)) + NIL))) + +(defun parse-commandline-args () + (when (cmd-parameter "--version" T) (print-version) (quit)) + (when (cmd-parameter "--help" T) (print-help) (quit)) + (let ((server (cmd-parameter "--server")) + (world-file (cmd-parameter "--world")) + (client (cmd-parameter "--client"))) + ;(break) + (if (or world-file server) ;TODO change OR to AND + (load-file world-file) + (format t "~&Sorry, the client is not yet available!")))) (if *args* diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 0bbe63b..e22c126 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -67,12 +67,24 @@ ((equalp choice 'e) (format t "~&Goodbye!") (quit)))) -;; TODO -;; (defun parse-commandline-args () -;; (do* ((i 0 (1+ i)) (a (nth i *args*) (nth i *args)) -;; (param-functions '(("--version" (#'print-version 0)) -;; ("--help" (#'print-help 0)) -;; ("--server" +(defun cmd-parameter (name &optional truth-value) + "Return the value of the parameter 'name'. Or T for present if truth-value." + (let ((argument (member name *args* :test #'equalp))) + (if argument + (if truth-value T + (second argument)) + NIL))) + +(defun parse-commandline-args () + (when (cmd-parameter "--version" T) (print-version) (quit)) + (when (cmd-parameter "--help" T) (print-help) (quit)) + (let ((server (cmd-parameter "--server")) + (world-file (cmd-parameter "--world")) + (client (cmd-parameter "--client"))) + ;(break) + (if (or world-file server) ;TODO change OR to AND + (load-file world-file) + (format t "~&Sorry, the client is not yet available!")))) (if *args* diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index d4b1721..bd97847 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -15,18 +15,12 @@ (load 'world.lisp) -;; (defun load-atl (atl-file) -;; ;not yet defined -;; NIL -;; ) - (defun define-place (name) (format t "~&Making place ~A" name) (make-place :name name)) (defun start-place (place) ;not yet defined - NIL ) (let ((world-directory NIL)) @@ -49,8 +43,10 @@ (incf line-nr) (setf line (concatenate 'string line (nth line-nr source)))) (cond ((zerop (length line)) - (when current-object (add-game-object current-object)) + ;; TODO + ;(when current-object (add-game-object current-object)) (setf current-object NIL)) + ((eql (aref line 0) #\;)) ;Comments are ignored ; interpret a define command ((not (or (eql (aref line 0) #\;) (eql (aref line 0) #\SPACE) @@ -68,7 +64,6 @@ (set-object-attribute current-object (read-from-string line) (read-from-string (second (cut-string line (find-char #\space line)))))) - ((eql (aref line 0) #\;)) ;Comments are ignored (T (format t "~&ERROR: unrecognized syntax on line ~A: '~A'" ;can't happen (1+ line-nr) line))))))