trying to fix a couple of bugs.
This commit is contained in:
@@ -40,16 +40,44 @@
|
||||
(defn has-one-of? [entities items]
|
||||
(seq (set/intersection (set (get-in entities [:state :inventory])) (set items))))
|
||||
|
||||
(defmacro run-action [entities & forms]
|
||||
`(let [c# (chan)]
|
||||
(do
|
||||
(put! (get-in (deref ~entities) [:actions :channel])
|
||||
(reify IAction
|
||||
(get-channel [_] c#)
|
||||
~@forms))
|
||||
(reset! ~entities (<!! c#)))))
|
||||
|
||||
(defn change-script-state [entities state]
|
||||
(run-action entities
|
||||
(begin [this screen entities]
|
||||
(assoc-in entities [:actions :script-running?] state))
|
||||
|
||||
(continue [this screen entities] entities)
|
||||
|
||||
(done? [this screen entities]
|
||||
true)
|
||||
|
||||
(terminate [this screen entities]
|
||||
entities)
|
||||
(can-skip? [this screen entities]
|
||||
false)))
|
||||
|
||||
(defmacro get-script [entities & forms]
|
||||
`(fn [starting-entities#]
|
||||
(let [~entities (atom starting-entities#)]
|
||||
(thread ~@forms
|
||||
(utils/save @~entities)))))
|
||||
(thread (do (change-script-state ~entities true)
|
||||
~@forms
|
||||
(change-script-state ~entities false)
|
||||
(utils/save @~entities))))))
|
||||
|
||||
(defmacro get-unsaved-script [entities & forms]
|
||||
`(fn [starting-entities#]
|
||||
(let [~entities (atom starting-entities#)]
|
||||
(thread ~@forms))))
|
||||
(thread (change-script-state ~entities true)
|
||||
~@forms
|
||||
(change-script-state ~entities false)))))
|
||||
|
||||
|
||||
(defn jump-to [screen entities entity [x y] update-baseline?]
|
||||
@@ -80,14 +108,7 @@
|
||||
(update-in entities [:room :entities target-id] (comp #(start-animation screen % :stand) (if face #(assoc % :facing face) identity))))
|
||||
|
||||
|
||||
(defmacro run-action [entities & forms]
|
||||
`(let [c# (chan)]
|
||||
(do
|
||||
(put! (get-in (deref ~entities) [:actions :channel])
|
||||
(reify IAction
|
||||
(get-channel [_] c#)
|
||||
~@forms))
|
||||
(reset! ~entities (<!! c#)))))
|
||||
|
||||
|
||||
(defn walk-straight-to [entities target-id [final-x final-y] & {:keys [update-baseline? face speed]}]
|
||||
(let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id])
|
||||
@@ -488,6 +509,8 @@
|
||||
(let [[[target line]] pairs
|
||||
next-speaker-is-different (not= target (ffirst (next pairs)))
|
||||
result (talk entities target line :stop? next-speaker-is-different)]
|
||||
|
||||
(Thread/sleep 200)
|
||||
(if (seq (rest pairs))
|
||||
(recur (rest pairs))
|
||||
result))))
|
||||
|
||||
Reference in New Issue
Block a user