trying to fix a couple of bugs.

This commit is contained in:
2014-12-14 09:26:30 -08:00
parent 97397c25df
commit 5995a7815b
3 changed files with 52 additions and 25 deletions

View File

@@ -124,7 +124,8 @@
(rooms/make :music :town-2
:interactions
{:door {:box [258 100 281 160]
:script (actions/get-unsaved-script
:script
(actions/get-unsaved-script
entities
(actions/walk-to entities :ego [267 90])
(actions/talk entities :ego (str "Anyone home?"))

View File

@@ -44,11 +44,12 @@
(get-in entities [:room :interactions]))))
(defn click-inventory [screen entities]
(if (= (get-in entities [:cursor :current] ) :main)
(do
(screen! inventory-screen :show-screen :items (map (entities :all-items) (get-in entities [:state :inventory])))
(assoc-in entities [:state :active?] false))
(assoc-in entities [:cursor :current] :main)))
(when (not (get-in entities [:actions :script-running?]))
(if (= (get-in entities [:cursor :current] ) :main)
(do
(screen! inventory-screen :show-screen :items (map (entities :all-items) (get-in entities [:state :inventory])))
(assoc-in entities [:state :active?] false))
(assoc-in entities [:cursor :current] :main))))
(defn left-click [screen entities]
@@ -61,8 +62,8 @@
(:get-script %)
((:mouse-in? %) entities x y))
(vals (get-in entities [:room :entities])))))
current-action (get-in entities [:actions :current])
;; TODO - hacky way of resetting queue
entities (if (and current-action (actions/can-skip? current-action screen entities))
(let [terminated-entities (actions/terminate current-action screen entities)]
@@ -70,16 +71,17 @@
(-> terminated-entities
(assoc-in [:actions :current] nil)
(assoc-in [:actions :started?] false))))
(assoc-in entities [:actions :channel] (chan)))]
entities)]
(if current-action
(if (get-in entities [:actions :script-running?])
entities
((or (when interaction
((or (when interacting-entity
((:get-script interacting-entity) (get-in entities [:cursor :current]) [x y]))
(when interaction
((:get-script interaction) (or (when (:cursor interaction) :main)
(get-in entities [:cursor :current]))
[x y]))
(when interacting-entity
((:get-script interacting-entity) (get-in entities [:cursor :current]) [x y]))
((:get-script default-interaction) (get-in entities [:cursor :current]) [x y])) entities))
entities))))
@@ -202,10 +204,10 @@
(let [terminated (actions/terminate current screen entities)]
(put! (actions/get-channel current) terminated)
(recur screen (assoc terminated
:actions {:channel channel :current nil :started? false})))
:actions {:channel channel :current nil :started? false :script-running? (get-in entities [:actions :script-running?])})))
(assoc-in entities [:actions :started?] true)))
(let [[current _] (alts!! [channel] :default nil)]
(assoc entities :actions {:channel channel :current current :started? false}))))
(assoc entities :actions {:channel channel :current current :started? false :script-running? (get-in entities [:actions :script-running?])}))))
(defn update-cursor [screen {{:keys [current override last]} :cursor :as entities}]
@@ -270,6 +272,7 @@
:actions {:object nil
:channel (chan)
:current nil
:script-running? false
:started? false}
:cursor {:id "cursor"
:current :main