|
|
|
|
|
(in-package txt2web.lib)
|
|
|
|
|
|
;;;; Macros implementing some intrinsics where it makes sense
|
|
|
;;;; E.g. an equivalent JS function exists, or it's a direct API call
|
|
|
|
|
|
;;; 1loc
|
|
|
|
|
|
;;; 2var
|
|
|
|
|
|
(defpsmacro killvar (&optional varname index)
|
|
|
`(api-call kill-var ,varname ,index))
|
|
|
|
|
|
(defpsmacro killall ()
|
|
|
`(progn
|
|
|
(killvar)
|
|
|
(killobj)))
|
|
|
|
|
|
;;; 3expr
|
|
|
|
|
|
(defpsmacro no (arg)
|
|
|
`(- -1 ,arg))
|
|
|
|
|
|
;;; 4code
|
|
|
|
|
|
(defpsmacro qspver ()
|
|
|
"0.0.1")
|
|
|
|
|
|
(defpsmacro curloc ()
|
|
|
`*current-location)
|
|
|
|
|
|
(defpsmacro rnd ()
|
|
|
`(funcall rand 1 1000))
|
|
|
|
|
|
(defpsmacro qspmax (&rest args)
|
|
|
(if (= 1 (length args))
|
|
|
`(*math.max.apply nil ,@args)
|
|
|
`(*math.max ,@args)))
|
|
|
|
|
|
(defpsmacro qspmin (&rest args)
|
|
|
(if (= 1 (length args))
|
|
|
`(*math.min.apply nil ,@args)
|
|
|
`(*math.min ,@args)))
|
|
|
|
|
|
;;; 5arrays
|
|
|
|
|
|
(defpsmacro arrsize (name)
|
|
|
`(api-call array-size ,name))
|
|
|
|
|
|
;;; 6str
|
|
|
|
|
|
(defpsmacro len (s)
|
|
|
`(length ,s))
|
|
|
|
|
|
(defpsmacro mid (s from &optional count)
|
|
|
`(chain ,s (substring ,from ,count)))
|
|
|
|
|
|
(defpsmacro ucase (s)
|
|
|
`(chain ,s (to-upper-case)))
|
|
|
|
|
|
(defpsmacro lcase (s)
|
|
|
`(chain ,s (to-lower-case)))
|
|
|
|
|
|
(defpsmacro trim (s)
|
|
|
`(chain ,s (trim)))
|
|
|
|
|
|
(defpsmacro qspreplace (s from to)
|
|
|
`(chain ,s (replace ,from ,to)))
|
|
|
|
|
|
(defpsmacro val (s)
|
|
|
`(parse-int ,s 10))
|
|
|
|
|
|
(defpsmacro qspstr (n)
|
|
|
`(chain ,n (to-string)))
|
|
|
|
|
|
;;; 7if
|
|
|
|
|
|
;;; 8sub
|
|
|
|
|
|
;;; 9loops
|
|
|
|
|
|
;; JUMP is in ps-macros.lisp (because it's a part of a huge kludge)
|
|
|
|
|
|
(defpsmacro exit ()
|
|
|
`(return-from nil (values)))
|
|
|
|
|
|
;;; 10dynamic
|
|
|
|
|
|
(defpsmacro dynamic (block &rest args)
|
|
|
`(progn
|
|
|
(when (stringp ,block)
|
|
|
(api:report-error "DYNAMIC can't evaluate arbitrary strings.\\nUse {braces} to create blocks for DYNAMIC."))
|
|
|
(api:with-call-args ,args
|
|
|
(funcall ,block))
|
|
|
(void)))
|
|
|
|
|
|
(defpsmacro dyneval (block &rest args)
|
|
|
`(progn
|
|
|
(when (stringp block)
|
|
|
(api:report-error "DYNEVAL can't evaluate arbitrary strings.\\nUse {braces} to create blocks for DYNEVAL."))
|
|
|
(api:with-call-args args
|
|
|
(funcall block))))
|
|
|
|
|
|
;;; 11main
|
|
|
|
|
|
(defpsmacro desc (s)
|
|
|
(declare (ignore s))
|
|
|
"")
|
|
|
|
|
|
;;; 12stat
|
|
|
|
|
|
(defpsmacro showstat (enable)
|
|
|
`(api-call enable-frame :stat ,enable))
|
|
|
|
|
|
;;; 13diag
|
|
|
|
|
|
(defpsmacro msg (text)
|
|
|
`(alert ,text))
|
|
|
|
|
|
;;; 14act
|
|
|
|
|
|
(defpsmacro showacts (enable)
|
|
|
`(api-call enable-frame :acts ,enable))
|
|
|
|
|
|
(defpsmacro delact (&optional name)
|
|
|
(if name
|
|
|
`(api-call del-act ,name)
|
|
|
`(api-call del-act)))
|
|
|
|
|
|
(defpsmacro cla ()
|
|
|
`(api-call clear-act))
|
|
|
|
|
|
;;; 15objs
|
|
|
|
|
|
(defpsmacro showobjs (enable)
|
|
|
`(api-call enable-frame :objs ,enable))
|
|
|
|
|
|
(defpsmacro countobj ()
|
|
|
`(length *objs))
|
|
|
|
|
|
(defpsmacro getobj (index)
|
|
|
`(or (elt *objs ,index) ""))
|
|
|
|
|
|
;;; 16menu
|
|
|
|
|
|
;;; 17sound
|
|
|
|
|
|
(defpsmacro isplay (filename)
|
|
|
`(funcall (@ playing includes) ,filename))
|
|
|
|
|
|
;;; 18img
|
|
|
|
|
|
(defpsmacro view (&optional path)
|
|
|
`(api-call show-image ,path))
|
|
|
|
|
|
;;; 19input
|
|
|
|
|
|
(defpsmacro showinput (enable)
|
|
|
`(api-call enable-frame :input ,enable))
|
|
|
|
|
|
;;; 20time
|
|
|
|
|
|
(defpsmacro wait (msec)
|
|
|
`(await (api-call sleep ,msec)))
|
|
|
|
|
|
(defpsmacro settimer (interval)
|
|
|
`(api-call set-timer ,interval))
|
|
|
|
|
|
;;; 21local
|
|
|
|
|
|
;;; 22for
|
|
|
|
|
|
;;; misc
|
|
|
|
|
|
(defpsmacro opengame (&optional filename)
|
|
|
(declare (ignore filename))
|
|
|
`(api-call opengame))
|
|
|
|
|
|
(defpsmacro savegame (&optional filename)
|
|
|
(declare (ignore filename))
|
|
|
`(api-call savegame))
|
|
|
|