# HG changeset patch # User # Date 2020-04-09 19:04:21 # Node ID 097aa130a2d7ec1bda3683f512a531da3a3bd6f1 # Parent 0d95d95b808b5f5a296f63385e811196c5e398fd Bugfixes diff --git a/src/api.ps b/src/api.ps --- a/src/api.ps +++ b/src/api.ps @@ -30,6 +30,9 @@ (defun make-menu-delimiter () "
") +(defun copy-obj (obj) + (chain *j-s-o-n (parse (chain *j-s-o-n (stringify obj))))) + (defun report-error (text) (alert text)) @@ -139,12 +142,15 @@ (setf name (chain name (to-upper-case))) (with-frame (with-call-args args - (funcall (getprop *locs name))))) + (funcall (getprop *locs name)))) + (void)) (defun call-act (title) - (let ((*current-act title)) - (with-frame - (funcall (getprop *acts title :act))))) + (setf *current-action title) + (with-frame + (funcall (getprop *acts title :act))) + (setf *current-action nil) + (void)) ;;; Text windows @@ -184,7 +190,7 @@ (create :title title :img img :act act :selected nil)) (update-acts)) -(defun del-act (title) +(defun del-act (&optional title) (delete (getprop *acts (or title *current-action))) (update-acts)) @@ -225,7 +231,7 @@ v)) (defun set-str-element (slot index value) - (if (in index (getprop slot :indexes)) + (if (has index (getprop slot :indexes)) (setf (elt (getprop slot) (getprop slot :indexes index)) value) diff --git a/src/intrinsic-macros.lisp b/src/intrinsic-macros.lisp --- a/src/intrinsic-macros.lisp +++ b/src/intrinsic-macros.lisp @@ -16,12 +16,6 @@ ;;; 3expr -(defpsmacro obj (name) - `(in ,name *objs)) - -(defpsmacro loc (name) - `(in ,name *locs)) - (defpsmacro no (arg) `(- -1 ,arg)) @@ -115,7 +109,9 @@ `(api-call enable-frame :acts ,enable)) (defpsmacro delact (&optional name) - `(api-call del-act ,name)) + (if name + `(api-call del-act ,name) + `(api-call del-act))) (defpsmacro cla () `(api-call clear-act)) diff --git a/src/intrinsics.ps b/src/intrinsics.ps --- a/src/intrinsics.ps +++ b/src/intrinsics.ps @@ -25,6 +25,12 @@ ;;; 3expr +(defun obj (name) + (has name *objs)) + +(defun loc (name) + (has name *locs)) + ;;; 4code (defun rand (a &optional (b 1)) @@ -186,7 +192,7 @@ ;;; 14act (defun curacts () - (let ((acts *acts)) + (let ((acts (api-call copy-obj *acts))) (lambda () (setf *acts acts) (void)))) @@ -203,6 +209,7 @@ (defun delobj (name) (delete (getprop *objs name)) + (api:update-objs) (api-call call-serv-loc "$ONOBJDEL" name) (void)) diff --git a/src/main-macros.lisp b/src/main-macros.lisp --- a/src/main-macros.lisp +++ b/src/main-macros.lisp @@ -1,12 +1,8 @@ (in-package sugar-qsp.main) - -(defpsmacro by-id (id) - `(chain document (get-element-by-id ,id))) - (defmacro+ps api-call (name &rest args) `(,(intern (string-upcase name) "API") ,@args)) -(defpsmacro in (key obj) +(defpsmacro has (key obj) `(chain ,obj (has-own-property ,key))) diff --git a/src/main.ps b/src/main.ps --- a/src/main.ps +++ b/src/main.ps @@ -36,7 +36,6 @@ ;; Active locations (var *locs (create)) -;; Launch the game from the first location (setf (@ window onload) (lambda () (#.(intern "INIT-DOM" "SUGAR-QSP.API")) @@ -49,3 +48,8 @@ (#.(intern "RUN-GAME" "SUGAR-QSP.API") (chain *object (keys *games) 0)) (values))) + +;;; Some very common utilities (for both api and lib) + +(defun by-id (id) + (chain document (get-element-by-id id))) diff --git a/src/package.lisp b/src/package.lisp --- a/src/package.lisp +++ b/src/package.lisp @@ -6,7 +6,7 @@ (defpackage :sugar-qsp.main (:use :cl :ps :sugar-qsp.js) (:export #:api-call #:by-id - #:in + #:has #:*globals #:*objs #:*current-location #:*current-action #:*started-at #:*timer-interval #:*timer-obj #:*loaded-games diff --git a/src/parser.lisp b/src/parser.lisp --- a/src/parser.lisp +++ b/src/parser.lisp @@ -15,7 +15,6 @@ (defun not-quote (char) (not (eql #\' char))) - (defun not-doublequote (char) (not (eql #\" char)))