##// END OF EJS Templates
Fix
Fix

File last commit:

r67:d0477458 default
r67:d0477458 default
Show More
intrinsics.ps
328 lines | 7.4 KiB | application/postscript | PostScriptLexer
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Actually fix it
r53 (in-package txt2web.lib)
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Tutorial game works!
r6 ;;;; Functions and procedures defined by the QSP language.
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 ;;;; They can call api and deal with locations and other data directly.
;;;; Except vars. Use VAR and SET or GET-VAR and SET-VAR api calls.
;;; 1loc
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun goto (target args)
(api:clear-text :main)
MENU
r30 (funcall xgoto target args)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun xgoto (target args)
Multiple sources, multiple games, openqst/addqst/killqst
r31 (setf args (or args (list)))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (api:clear-act)
Globals instead of ROOT object
r39 (setf *current-location (chain target (to-upper-case)))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (api:stash-state args)
Globals instead of ROOT object
r39 (api:call-loc *current-location args)
Bugfixes to optimized variables. CURACT, DELACT
r40 (api:call-serv-loc "$ONNEWLOC")
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
;;; 2var
;;; 3expr
Bugfixes
r41 (defun obj (name)
(has name *objs))
(defun loc (name)
(has name *locs))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 ;;; 4code
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun rand (a &optional (b 1))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 (let ((min (min a b))
(max (max a b)))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (+ min (chain *math (random (- max min))))))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
;;; 5arrays
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun copyarr (to from start count)
Properly handle stringly-indexed arrays
r16 (multiple-value-bind (to-name to-slot)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (api:var-real-name to)
Properly handle stringly-indexed arrays
r16 (multiple-value-bind (from-name from-slot)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (api:var-real-name from)
Actually fix it
r53 (loop :for i :from start :to (min (api:array-size from-name)
(+ start count))
:do (api:set-var to-name (+ start i) to-slot
(api:get-var from-name (+ start i) from-slot))))))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun arrpos (name value &optional (start 0))
Properly handle stringly-indexed arrays
r16 (multiple-value-bind (real-name slot)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (api:var-real-name name)
Actually fix it
r53 (loop :for i :from start :to (api:array-size name)
:do (when (eq (api:get-var real-name i slot) value)
(return-from arrpos i))))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 -1)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun arrcomp (name pattern &optional (start 0))
Properly handle stringly-indexed arrays
r16 (multiple-value-bind (real-name slot)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (api:var-real-name name)
Actually fix it
r53 (loop :for i :from start :to (api:array-size name)
:do (when (funcall (getprop (api:get-var real-name i slot)
'match)
pattern)
(return-from arrcomp i))))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 -1)
;;; 6str
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun instr (s subs &optional (start 1))
(+ start (chain s (substring (- start 1)) (search subs))))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun isnum (s)
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 (if (is-na-n s)
0
-1))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun strcomp (s pattern)
(if (chain s (match pattern))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 -1
0))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun strfind (s pattern group)
(let* ((re (new (*reg-exp pattern)))
(match (chain re (exec s))))
(chain match (group group))))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun strpos (s pattern &optional (group 0))
(let* ((re (new (*reg-exp pattern)))
(match (chain re (exec s)))
(found (chain match (group group))))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 (if found
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (chain s (search found))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 0)))
;;; 7if
Menu, game saving
r11 ;; Has to be a function because it always evaluates all three of its
;; arguments
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun iif (cond-expr then-expr else-expr)
Menu, game saving
r11 (if cond-expr then-expr else-expr))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
;;; 8sub
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun gosub (target &rest args)
MENU
r30 (api:call-loc target args)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun func (target &rest args)
MENU
r30 (api:call-loc target args))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
;;; 9loops
;;; 10dynamic
Fix
r67 (defun dynamic (block &rest args)
(when (stringp block)
(api:report-error "DYNAMIC can't evaluate arbitrary strings.\\nUse {braces} to create blocks for DYNAMIC."))
(api:with-call-args args nil
(funcall block)))
(defun dyneval (block &rest args)
(when (stringp block)
(api:report-error "DYNEVAL can't evaluate arbitrary strings.\\nUse {braces} to create blocks for DYNEVAL."))
(api:with-call-args args t
(funcall block)))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 ;;; 11main
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun main-p (s)
(api:add-text :main s)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun main-pl (s)
(api:add-text :main s)
(api:newline :main)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun main-nl (s)
(api:newline :main)
(api:add-text :main s)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Fix a bug with kill-var and calling service locations
r66 (defun maintxt ()
(api:get-text :main))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Fix a bug with kill-var and calling service locations
r66 (defun desc ()
Use flex in html
r10 "")
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun main-clear ()
(api:clear-text :main)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Tutorial game works!
r6 ;;; 12stat
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun stat-p (s)
(api:add-text :stat s)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun stat-pl (s)
(api:add-text :stat s)
(api:newline :stat)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun stat-nl (s)
(api:newline :stat)
(api:add-text :stat s)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Fix a bug with kill-var and calling service locations
r66 (defun stattxt ()
(api:get-text :stat))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun stat-clear ()
(api:clear-text :stat)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun cls ()
(stat-clear)
(main-clear)
(cla)
(cmdclear)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
;;; 13diag
;;; 14act
Remove curact, implement selact
r45 (defun selact ()
(loop :for (k v) :of *acts
:do (when (@ v :selected)
(return-from selact (@ v :name)))))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun curacts ()
Fix
r67 (let ((acts (chain *object (assign (create) *acts))))
Menu, game saving
r11 (lambda ()
Globals instead of ROOT object
r39 (setf *acts acts)
Fix
r67 (api:update-acts)
Removing unnecessary returns
r27 (void))))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
;;; 15objs
Special variables and locations
r32 (defun addobj (name img)
(setf img (or img ""))
Globals instead of ROOT object
r39 (setf (getprop *objs name)
Special variables and locations
r32 (create :name name :img img :selected nil))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (api:update-objs)
Bugfixes to optimized variables. CURACT, DELACT
r40 (api-call call-serv-loc "$ONOBJADD" name img)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun delobj (name)
Globals instead of ROOT object
r39 (delete (getprop *objs name))
Bugfixes
r41 (api:update-objs)
Bugfixes to optimized variables. CURACT, DELACT
r40 (api-call call-serv-loc "$ONOBJDEL" name)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun killobj (&optional (num nil))
Fix two regressions
r64 (if (eq undefined num)
Globals instead of ROOT object
r39 (setf *objs (create))
(delobj (elt (chain *object (keys *objs)) num)))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (api:update-objs)
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Special variables and locations
r32 (defun selobj ()
Globals instead of ROOT object
r39 (loop :for (k v) :of *objs
Special variables and locations
r32 :do (when (@ v :selected)
(return-from selobj (@ v :name)))))
Bugfixes
r56 (defun unsel ()
(loop :for (k v) :of *objs
:do (setf (@ v :selected) nil)))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 ;;; 16menu
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun menu (menu-name)
Menu, game saving
r11 (let ((menu-data (list)))
MENU
r30 (loop :for item-obj :in (@ (api:get-array (api:var-real-name menu-name)) values)
:for item := (@ item-obj :str)
Menu, game saving
r11 :do (cond ((string= item "")
(break))
((string= item "-:-")
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (chain menu-data (push :delimiter)))
Menu, game saving
r11 (t
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (let* ((tokens (chain item (split ":"))))
Menu, game saving
r11 (when (= (length tokens) 2)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (chain tokens (push "")))
(let* ((text (chain tokens (splice 0 (- (length tokens) 2)) (join ":")))
(loc (getprop tokens (- (length tokens) 2)))
(icon (getprop tokens (- (length tokens) 1))))
(chain menu-data
MENU
r30 (push (create :text text
:loc loc
:icon icon))))))))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (api:menu menu-data)
Removing unnecessary returns
r27 (void)))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
;;; 17sound
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun play (filename &optional (volume 100))
(let ((audio (new (*audio filename))))
Globals instead of ROOT object
r39 (setf (getprop *playing filename) audio)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (@ audio volume) (* volume 0.01))
(chain audio (play))))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun close (filename)
Globals instead of ROOT object
r39 (funcall (getprop *playing filename) stop)
(delete (getprop *playing filename))
Removing unnecessary returns
r27 (void))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun closeall ()
Globals instead of ROOT object
r39 (loop :for k :in (chain *object (keys *playing))
:for v := (getprop *playing k)
Sounds, save/load UI buttons
r12 :do (funcall v stop))
Globals instead of ROOT object
r39 (setf *playing (create)))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
;;; 18img
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun refint ()
Some DOM stuff, VIEW
r18 ;; "Force interface update" Uh... what exactly do we do here?
IMG and *IMG
r34 ;(api:report-error "REFINT is not supported")
Some DOM stuff, VIEW
r18 )
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
;;; 19input
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun usertxt ()
(let ((input (by-id "qsp-input")))
(@ input value)))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun cmdclear ()
(let ((input (by-id "qsp-input")))
(setf (@ input value) "")))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun input (text)
(chain window (prompt text)))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
;;; 20time
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun msecscount ()
Globals instead of ROOT object
r39 (- (chain *date (now)) *started-at))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Locals
r14 ;;; 21local
Some DOM stuff, VIEW
r18 ;;; 22for
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 ;;; misc
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun rgb (red green blue)
Special variables and locations
r32 (+ (<< red 16)
(<< green 8)
blue))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Multiple sources, multiple games, openqst/addqst/killqst
r31 (defun openqst (name)
(api-call run-game name))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Multiple sources, multiple games, openqst/addqst/killqst
r31 (defun addqst (name)
(let ((game (api-call filename-game name)))
;; Add the game's locations
Globals instead of ROOT object
r39 (chain *object (assign *locs
(getprop *games name)))))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun killqst ()
Multiple sources, multiple games, openqst/addqst/killqst
r31 ;; Delete all locations not from the current main game
Globals instead of ROOT object
r39 (loop :for (k v) :in *games
:do (unless (string= k *main-game)
(delete (getprop *locs k)))))
Multiple sources, multiple games, openqst/addqst/killqst
r31