From 1bc93078cc5c2801236a5a6f57bb56ae5081a844 Mon Sep 17 00:00:00 2001 From: troido Date: Thu, 4 Jan 2018 14:05:06 +0100 Subject: no quotes necessary anymore in keybindings keys. Added some macros --- asciifarm/client/inputhandling.hy | 2 +- asciifarm/client/keymacros.hy | 12 +++++++++ asciifarm/keybindings/keybindings.hy | 52 ++++++++++++++++++------------------ 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/asciifarm/client/inputhandling.hy b/asciifarm/client/inputhandling.hy index dbe5dd4..64b67e7 100644 --- a/asciifarm/client/inputhandling.hy +++ b/asciifarm/client/inputhandling.hy @@ -13,7 +13,7 @@ (defn readCommands [self commandsstring] (setv self.commands (dict-comp - (eval key) + (str key) ( (eval `(do (require [asciifarm.client.keymacros [*]]) diff --git a/asciifarm/client/keymacros.hy b/asciifarm/client/keymacros.hy index b39ef5e..65e2993 100644 --- a/asciifarm/client/keymacros.hy +++ b/asciifarm/client/keymacros.hy @@ -6,6 +6,18 @@ (defmacro inp [action] `(send ["input" ~action])) +(defmacro move [dir] + `(inp ["move" ~dir])) + +(defmacro say [text] + `(inp ["say" ~text])) + +(defmacro log [text] + `(self.client.log ~text)) + +(defmacro chat [text] + `(send ["chat" ~text])) + (defmacro doall [actions] `(for [action ~actions] (action))) diff --git a/asciifarm/keybindings/keybindings.hy b/asciifarm/keybindings/keybindings.hy index 14fe190..2784bad 100644 --- a/asciifarm/keybindings/keybindings.hy +++ b/asciifarm/keybindings/keybindings.hy @@ -1,35 +1,35 @@ { -"w" (inp ["move" "north"]) -"s" (inp ["move" "south"]) -"d" (inp ["move" "east"]) -"a" (inp ["move" "west"]) -"KEY_UP" (inp ["move" "north"]) -"KEY_DOWN" (inp ["move" "south"]) -"KEY_RIGHT" (inp ["move" "east"]) -"KEY_LEFT" (inp ["move" "west"]) -"k" (inp ["move" "north"]) -"j" (inp ["move" "south"]) -"l" (inp ["move" "east"]) -"h" (inp ["move" "west"]) -"e" (inp ["take" (selectorvalue "ground")]) -"q" (inp ["drop" (selectorvalue "inventory")]) -"E" (inp ["use" (selectorvalue "inventory")]) -"r" (inp ["interact" (selectorvalue "ground")]) -"v" (.select (selector "inventory") 1 True True) -"c" (.select (selector "ground") 1 True True) -"x" (.select (selector "equipment") 1 True True) -"z" (inp ["unequip" (selectorvalue "equipment")]) -"f" (do [ +w (inp ["move" "north"]) +s (inp ["move" "south"]) +d (inp ["move" "east"]) +a (inp ["move" "west"]) +KEY_UP (inp ["move" "north"]) +KEY_DOWN (inp ["move" "south"]) +KEY_RIGHT (inp ["move" "east"]) +KEY_LEFT (inp ["move" "west"]) +k (inp ["move" "north"]) +j (inp ["move" "south"]) +l (inp ["move" "east"]) +h (inp ["move" "west"]) +e (inp ["take" (selectorvalue "ground")]) +q (inp ["drop" (selectorvalue "inventory")]) +E (inp ["use" (selectorvalue "inventory")]) +r (inp ["interact" (selectorvalue "ground")]) +v (.select (selector "inventory") 1 True True) +c (.select (selector "ground") 1 True True) +x (.select (selector "equipment") 1 True True) +z (inp ["unequip" (selectorvalue "equipment")]) +f (do [ (inp ["attack"]) (inp ["attack" "north"]) (inp ["attack" "south"]) (inp ["attack" "east"]) (inp ["attack" "west"])]) -"t" (self.parseMessage (self.display.getString)) -"NEWLINE" (self.parseMessage (self.display.getString)) -"KEY_PPAGE" (self.display.scrollBack 1) -"KEY_NPAGE" (self.display.scrollBack -1) -"help" "\ +t (self.parseMessage (self.display.getString)) +NEWLINE (self.parseMessage (self.display.getString)) +KEY_PPAGE (self.display.scrollBack 1) +KEY_NPAGE (self.display.scrollBack -1) +help "\ Controls: wasd or arrows: Move around -- cgit