summaryrefslogtreecommitdiff
path: root/asciifarm/client/keybindings.hy
diff options
context:
space:
mode:
authortroido <troido@hotmail.com>2017-12-29 22:10:16 +0100
committertroido <troido@hotmail.com>2017-12-29 22:10:16 +0100
commita1c60cfcb63b013f575943e17854cf205f8db913 (patch)
treead3829ef22dab6e9082728dc400b14eb06d94fdc /asciifarm/client/keybindings.hy
parent26c5eb315a4512a53a51a85abf4c0385b978c2f5 (diff)
made selectors for inventorypad and made key config in hy
Diffstat (limited to 'asciifarm/client/keybindings.hy')
-rw-r--r--asciifarm/client/keybindings.hy38
1 files changed, 38 insertions, 0 deletions
diff --git a/asciifarm/client/keybindings.hy b/asciifarm/client/keybindings.hy
new file mode 100644
index 0000000..d91d6f5
--- /dev/null
+++ b/asciifarm/client/keybindings.hy
@@ -0,0 +1,38 @@
+
+(defmacro send [data]
+ `(fn [client] (client.send ~data)))
+
+(defmacro input [action]
+ `(send ["input" ~action]))
+
+(defmacro doall [actions]
+ `(fn [client] (for [action ~actions] (action client))))
+
+(defmacro selector [name]
+ `(.getSelector (.getDisplay client) ~name))
+
+(defmacro selectorvalue [name]
+ `(.getValue (selector ~name)))
+
+(setv commands {
+ "w" (input ["move" "north"])
+ "s" (input ["move" "south"])
+ "d" (input ["move" "east"])
+ "a" (input ["move" "west"])
+ "KEY_UP" (input ["move" "north"])
+ "KEY_DOWN" (input ["move" "south"])
+ "KEY_RIGHT" (input ["move" "east"])
+ "KEY_LEFT" (input ["move" "west"])
+ "e" (input ["take" (selectorvalue "ground")])
+ "q" (input ["drop" (selectorvalue "inventory")])
+ "E" (input ["use" (selectorvalue "inventory")])
+ "r" (input ["interact" (selectorvalue "ground")])
+ "f" (doall [
+ (input ["attack"])
+ (input ["attack" "north"])
+ (input ["attack" "south"])
+ (input ["attack" "east"])
+ (input ["attack" "west"])])
+ "t" (fn [client] (client.readString))
+
+})