diff options
| author | troido <troido@hotmail.com> | 2017-12-29 22:40:24 +0100 |
|---|---|---|
| committer | troido <troido@hotmail.com> | 2017-12-29 22:40:24 +0100 |
| commit | 29149f398986620cf13ba1fc4d2d7cca139bead0 (patch) | |
| tree | d8f7915bdf656599319ab5dd63d3873b9f8c59a3 /asciifarm/client/keybindings.hy | |
| parent | a1c60cfcb63b013f575943e17854cf205f8db913 (diff) | |
keybinding macros have their own file and selectors can now be used!
Diffstat (limited to 'asciifarm/client/keybindings.hy')
| -rw-r--r-- | asciifarm/client/keybindings.hy | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/asciifarm/client/keybindings.hy b/asciifarm/client/keybindings.hy index d91d6f5..d2b129f 100644 --- a/asciifarm/client/keybindings.hy +++ b/asciifarm/client/keybindings.hy @@ -1,38 +1,27 @@ -(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))) +(require [asciifarm.client.keymacros [*]]) (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 [ + "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")]) + "v" (fn [client] (.select (selector "inventory") 1 True True)) + "c" (fn [client] (.select (selector "ground") 1 True True)) +;; "x" (fn [client] (.select (selector "equipment") 1 True True)) + "f" (doall [ (input ["attack"]) (input ["attack" "north"]) (input ["attack" "south"]) (input ["attack" "east"]) (input ["attack" "west"])]) - "t" (fn [client] (client.readString)) - -}) + "t" (fn [client] (client.readString)) }) |
