From 6fda6d80b52e806628d406f953c0cc1623b31d45 Mon Sep 17 00:00:00 2001 From: Remington Covert Date: Fri, 28 Nov 2014 12:04:41 -0800 Subject: [PATCH] added manually saving scripts. --- desktop/src-common/advent/actions.clj | 5 +++++ desktop/src-common/advent/screens/rooms/outside_house.clj | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 2a9325a2..621b9810 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -38,6 +38,11 @@ (thread ~@forms (utils/save @~entities))))) +(defmacro get-unsaved-script [entities & forms] + `(fn [starting-entities#] + (let [~entities (atom starting-entities#)] + (thread ~@forms)))) + (defn jump-to [screen entities entity [x y] update-baseline?] (let [scale-fn (-> entities :room :scale-fn) diff --git a/desktop/src-common/advent/screens/rooms/outside_house.clj b/desktop/src-common/advent/screens/rooms/outside_house.clj index 3f8898d4..47f8b8e0 100644 --- a/desktop/src-common/advent/screens/rooms/outside_house.clj +++ b/desktop/src-common/advent/screens/rooms/outside_house.clj @@ -98,7 +98,8 @@ :wizard "If this is truely your quest, boy, then I will help you in your quest. " :wizard "But heed the warning from the prophecy: No cheat can pull the Sword of Blergh." :ego "No cheating." - :ego "Check."))}]} + :ego "Check.") + (utils/save @entities))}]} "By besting swamp, foe, and the occasional bizarre conversation tree." {:run #(do (actions/respond entities % :wizard "While your goal sounds noble, no amount of bizarre conversation tree searching will earn my respect." @@ -121,14 +122,15 @@ (rooms/make :music :town-2 :interactions {:door {:box [258 100 281 160] - :script (actions/get-script + :script (actions/get-unsaved-script entities (actions/walk-to entities :ego [267 90]) (actions/talk entities :ego (str "Anyone home?")) (actions/play-animation entities :ego :reach) (actions/transition-background entities :inside-house [237 0]) (if (get-in @entities [:state :convinced-wizard?]) - (actions/talk entities :wizard (str "Oh, hello there boy.")) + (do (actions/talk entities :wizard (str "Oh, hello there boy.")) + (utils/save @entities)) (wizard-dialogue entities)))} :sword {:box [274 55 305 88] :script (actions/get-script