;;; ;;; Atlantis is a framework for creating multi-user dungeon worlds. ;;; This is the Common Lisp implementation. ;;; ;;; This is an ATL code-generating module to ease the world creation ;;; process for non-coders (and those too lazy to write more than ;;; necessary...). ;;; ;;; Licensed under the terms of the MIT license. ;;; author: Daniel Vedder ;;; date: 20/06/2015 ;;; (defun import-spreadsheet (spreadsheet atl-file) "Import and convert a spreadsheet (requires LibreOffice)" (let* ((ods-pathname (parse-namestring spreadsheet)) (csv-pathname (make-pathname :directory (pathname-directory ods-pathname) :name (pathname-name ods-pathname) :type "csv"))) ;; Convert the spreadsheet to csv (only works with clisp!) (ext:shell (format nil "libreoffice --headless --convert-to csv ~A~A~A" (namestring ods-pathname) " --outdir " (namestring (make-pathname :directory (pathname-directory ods-pathname))))) (csv-to-atl csv-pathname atl-file))) (defun csv-to-atl (csv-pathname atl-file &aux (atl-code "")) "Convert a csv file to ATL" (setf atl-code ";; This code has been automatically generated by the ;; Atlantis world creator.") (do* ((csv-file (load-text-file csv-pathname)) (line-nr 2 (1+ line-nr)) (object-type (read-from-string (first (split-string (first csv-file) #\,)))) (object-characteristics (split-string (second csv-file) #\,)) (line (nth line-nr csv-file) (nth line-nr csv-file)) (line-values (split-string line #\,) (split-string line #\,))) ((null line) NIL) ;; Start a new define-command (setf atl-code (format NIL "~A~&~%~A" atl-code (concatenate 'string "define-" (string-downcase (to-string object-type)) " " (first line-values)))) ;; Enter the value for each characteristic (dotimes (i (1- (length object-characteristics))) (setf atl-code (format NIL "~A~&~A" atl-code (concatenate 'string (to-string #\tab) (nth (1+ i) object-characteristics) " " (nth (1+ i) line-values)))))) ;; Write the generated code to file (with-open-file (atl atl-file :direction :output) (format atl "~A" atl-code))) (defun world-creator () "The UI for the functions in this module" (format t "~&Sorry, not yet available!"))