:addword :word2dic :addword2dic\r
:split-to-words :sprint\r
:parser :description :article :glance \r
- :initnames :addnames\r
- :read-property :read-property-string :read-property-number\r
- :read-property-integer :read-property-object :read-property-execute\r
- :read-property-other :read-property-list :exec :exec*\r
+ :initnames :addnames \r
+ :read-property :rp :read-property- \r
+ :exec :exec*\r
:abstractobject :name :names :parent :children :flags\r
:initflags :add-flags :has :hasnt :-> :give\r
:ifclass :object :defaction :*meta*\r
"make defvars for names"\r
`(progn\r
,@(loop for x in names\r
- collect `(defvar ,x))))\r
+ collect `(defvar ,x nil))))\r
\r
;;SECTION 2: Global parameters and definitions\r
\r
\r
(defun give (obj &rest flags) \r
"Informish synonim to add-flags." \r
- (setf (flags obj) (combine-flags (append (flags obj) flags))))\r
+ (setf (flags obj) (combine-flags (append (flags obj) flags))) nil)\r
\r
(defun has (obj &rest flags)\r
"Informish macro has. Unlike Inform, can accept several flags."\r
(glance (apply #'read-property-string (slot-value self property) args))\r
(t (slot-value self property))))\r
\r
+(defun read-property- (method self property &rest args)\r
+ "read-property using specific method. method is one of keywords:\r
+ :string :number :object :integer :"\r
+ (case method\r
+ (:string (apply #'read-property-string (slot-value self property) args))\r
+ (:number (apply #'read-property-string (slot-value self property) args))\r
+ (:integer (apply #'read-property-string (slot-value self property) args))\r
+ (:object (apply #'read-property-string (slot-value self property) args))\r
+ (:execute (apply #'read-property-string (slot-value self property) args))\r
+ (:list (apply #'read-property-string (slot-value self property) args))\r
+ (t (slot-value self property))))\r
\r
;;SECTION 7: IfClass macro and its hairy surroundings\r
\r
:reset-scope :look :words2dic-first :disambig :normal-token-scope\r
:input-quit-loop :quit-game :prompt :prompt-read :input-loop-step\r
:go-to-room :property :init :test-seq\r
- :heldp :the-name :each-turn\r
+ :heldp :the-name :each-turn :daemon :time-left :time-out\r
+ :start-daemon :stop-daemon :start-timer :stop-timer \r
:supporter :animate :scenery\r
:afterlife :print-gamestate :end-game\r
- :repl-mode :compile-lib \r
+ :repl-mode :compile-lib :free-symbol \r
)\r
(:shadow :room))\r
\r
(defun print-property (obj property)\r
"Print a property of object"\r
(multiple-value-bind (value printp) (read-property obj property)\r
- (if (and (stringp value) (not printp)) (sprint value) value)))\r
+ (if (and (stringp value) (not printp)) (progn (sprint value) t) printp)))\r
\r
(defgeneric print-name (obj &key article capital)\r
(:documentation "Returns a string containing the name of object"))\r
(supply turn-passing (&optional time) \r
(reset-scope)\r
(incf *turns* time)\r
- (loop for x in *outscope*\r
+ (loop for x in *allobjects*\r
+ if (and (has x :daemon) (provides x 'daemon))\r
+ do (read-property- :execute x 'daemon)\r
+ if (and (has x :timer) (provides x 'time-left) \r
+ (provides x 'time-out))\r
+ do (if (zerop (slot-value x 'time-left))\r
+ (read-property- :execute x 'time-out)\r
+ (decf (slot-value x 'time-left))))\r
+ (loop for x in *outscope*\r
if (provides x 'each-turn)\r
- do (read-property-execute (slot-value x 'each-turn)))\r
+ do (read-property- :execute x 'each-turn)) \r
(call-next-method)) \r
\r
+(defun start-daemon (obj)\r
+ (give obj :daemon))\r
+\r
+(defun stop-daemon (obj)\r
+ (give obj :~daemon))\r
+\r
+(defun start-timer (obj time)\r
+ (assert (provides obj 'time-left))\r
+ (setf (slot-value obj 'time-left) time)\r
+ (give obj :timer))\r
+\r
+(defun stop-timer (obj)\r
+ (give obj :~timer))\r
+\r
(defgeneric before-special-rule (location)\r
(:documentation "Runs on location before other before effects are runned")\r
(:method (location) (declare (ignore location)) nil))\r
(:use :common-lisp :if-basic-lib :if-lib :verb-lib ,@other-packages)\r
(:shadowing-import-from :if-lib :room)\r
(:shadowing-import-from :verb-lib :listen)))\r
+\r
+(defmacro free-symbol (id)\r
+ "Frees a symbol from current package using shadow"\r
+ `(eval-when (:compile-toplevel :load-toplevel :execute)\r
+ (shadow ,id)))\r
+\r
\r
(defun repl-mode (&optional (mode :unspecified))\r
"Flip the using of REPL for input and output (as opposed to\r