From 2856bf796bf876b1d8c0298a424619e5b24f0878 Mon Sep 17 00:00:00 2001 From: Vftdan Date: Fri, 13 Oct 2023 13:45:25 +0300 Subject: [PATCH] Added hangglider_boost --- augment/files.json | 4 ++++ augment/modules/hangglider_boost.lua | 32 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 augment/modules/hangglider_boost.lua diff --git a/augment/files.json b/augment/files.json index c19913c..c8bd044 100644 --- a/augment/files.json +++ b/augment/files.json @@ -13,6 +13,10 @@ "path": "modules/event.lua", "src": "modules/event.lua" }, + { + "path": "modules/hangglider_boost.lua", + "src": "modules/hangglider_boost.lua" + }, { "path": "modules/wh.lua", "src": "modules/wh.lua" diff --git a/augment/modules/hangglider_boost.lua b/augment/modules/hangglider_boost.lua new file mode 100644 index 0000000..dc451f4 --- /dev/null +++ b/augment/modules/hangglider_boost.lua @@ -0,0 +1,32 @@ +return function() + local ni = peripheral.wrap("back") + + local sneakTicks = 0 + local meta = nil + local windowEvents = {nil, nil, nil} + local windowDuration = 20 + local clockCounter = 0 + + parallel.waitForAny( + function() while _G._running do + if meta and windowEvents[3] ~= nil and windowEvents[3] + windowDuration >= clockCounter then + local mainHand = meta.heldItem and meta.heldItem.getMetadata().name + local offHand = meta.offhandItem and meta.offhandItem.getMetadata().name + if mainHand == "openblocks:hang_glider" or offHand == "openblocks:hang_glider" then + ni.launch(meta.yaw, meta.pitch, 4) + end + end + os.sleep(0.05) + end end, + function() while _G._running do + meta = ni.getMetaOwner() + clockCounter = clockCounter + 1 + if meta.isSneaking then + sneakTicks = sneakTicks + 1 + elseif sneakTicks ~= 0 then + windowEvents = {clockCounter, windowEvents[1], windowEvents[2]} + sneakTicks = 0 + end + os.sleep(0.05) + end end) +end