From bb9f774081cb578fbcb9585cab3a32201972864c Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Fri, 11 Dec 2020 17:16:44 +0100 Subject: [PATCH] Initial Commit --- README | 2 ++ init.lua | 21 +++++++++++++++++++++ mod.conf | 3 +++ settingtypes.txt | 2 ++ 4 files changed, 28 insertions(+) create mode 100644 README create mode 100644 init.lua create mode 100644 mod.conf create mode 100644 settingtypes.txt diff --git a/README b/README new file mode 100644 index 0000000..1b0b85a --- /dev/null +++ b/README @@ -0,0 +1,2 @@ +# autokey +A dragonfire CSM to automatically press keys (Includes AutoSneak and AutoSprint) diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..9e42b07 --- /dev/null +++ b/init.lua @@ -0,0 +1,21 @@ +autokey = {} + +function autokey.register_keypress_cheat(setting, desc, category, keyname, condition) + local was_active = false + minetest.register_globalstep(function() + local is_active = minetest.settings:get_bool(setting) and (not condition or condition()) + if is_active then + minetest.set_keypress(keyname, true) + elseif was_active then + minetest.set_keypress(keyname, false) + end + was_active = is_active + end) + minetest.register_cheat(desc, category, setting) +end + +autokey.register_keypress_cheat("autosneak", "AutoSneak", "Movement", "sneak", function() + return core.localplayer:is_touching_ground() +end) + +autokey.register_keypress_cheat("autosprint", "AutoSneak", "Movement", "special1") diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..497562c --- /dev/null +++ b/mod.conf @@ -0,0 +1,3 @@ +name = autokey +author = Fleckenstein +description = A dragonfire CSM to automatically press keys (Includes AutoSneak and AutoSprint) diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..981ef24 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,2 @@ +autosneak (AutoSneak) bool false +autosprint (AutoSprint) bool false