From 838b7d5d691c005376cab915cb34965803faba32 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Thu, 28 Feb 2019 22:34:02 -0500 Subject: [PATCH] small updates + elytraFly hud --- farms/farmer.lua | 2 -- ignore/drops.lua | 4 +--- milo/apis/storage.lua | 9 +-------- milo/autorun/milo.lua | 2 ++ milo/plugins/learn.lua | 1 - neural/elytraFly.lua | 31 ++++++++++++++++++++++++++++++- 6 files changed, 34 insertions(+), 15 deletions(-) delete mode 100644 milo/plugins/learn.lua diff --git a/farms/farmer.lua b/farms/farmer.lua index 4df9598..c39fc52 100644 --- a/farms/farmer.lua +++ b/farms/farmer.lua @@ -1,5 +1,3 @@ -_G.requireInjector(_ENV) - local Point = require('point') local Util = require('util') diff --git a/ignore/drops.lua b/ignore/drops.lua index 7154a13..2a77d8d 100644 --- a/ignore/drops.lua +++ b/ignore/drops.lua @@ -24,9 +24,7 @@ while true do return acc end, { }) - Point.eachClosest(turtle.point, sensed, function(s) - turtle.suckDownAt(s) - end) + Point.eachClosest(turtle.point, sensed, turtle.suckDownAt) os.sleep(5) end diff --git a/milo/apis/storage.lua b/milo/apis/storage.lua index f294b46..dc808b6 100644 --- a/milo/apis/storage.lua +++ b/milo/apis/storage.lua @@ -231,20 +231,13 @@ _G._debug('STORAGE: Forcing full refresh') return self:listItems(throttle) end -local function Timer() - local ct = os.clock() - return function() - return os.clock() - ct - end -end - -- provide a consolidated list of items function Storage:listItems(throttle) if not self.dirty then return self.cache end - local timer = Timer() + local timer = Util.Timer() local cache = { } throttle = throttle or Util.throttle() diff --git a/milo/autorun/milo.lua b/milo/autorun/milo.lua index 7e17154..4a9a7a9 100644 --- a/milo/autorun/milo.lua +++ b/milo/autorun/milo.lua @@ -7,6 +7,8 @@ if fs.exists('packages/milo/Milo.lua') then fs.delete('packages/milo/plugins/listing.lua') end +fs.delete('packages/milo/apis/milo.lua') + if device.workbench then shell.openForegroundTab('MiloLocal') end diff --git a/milo/plugins/learn.lua b/milo/plugins/learn.lua deleted file mode 100644 index bc9235c..0000000 --- a/milo/plugins/learn.lua +++ /dev/null @@ -1 +0,0 @@ --- moved \ No newline at end of file diff --git a/neural/elytraFly.lua b/neural/elytraFly.lua index 33535ef..936ddc1 100644 --- a/neural/elytraFly.lua +++ b/neural/elytraFly.lua @@ -1,6 +1,7 @@ -- credit: osmarks https://pastebin.com/ZP9Q1HCT local Sound = require('sound') +local Util = require('util') local modules = _G.peripheral.wrap('back') local os = _G.os @@ -12,6 +13,30 @@ if not modules.launch or not modules.getMetaOwner then * Introspection module]]) end +local canvas = modules.canvas and modules.canvas() + +local function display(meta) + if canvas then + if not canvas.group then + canvas.group = canvas.addGroup({ 4, 90 }) + canvas.bg = canvas.group.addRectangle(0, 0, 60, 24, 0x00000033) + canvas.pitch = canvas.group.addText({ 4, 5 }, '') -- , 0x202020FF) + canvas.pitch.setShadow(true) + canvas.pitch.setScale(.75) + end + canvas.pitch.setText(string.format('Pitch: %s\nMotion Y: %s', + math.floor(-meta.pitch), + Util.round(meta.motionY, 2))) + end +end + +local function clearDisplay() + if canvas and canvas.group then + canvas.group.remove() + canvas.group = nil + end +end + local function run() local launchCounter = 0 @@ -23,14 +48,17 @@ local function run() if meta.pitch < 0 then -- looking up modules.launch(meta.yaw, meta.pitch, -meta.pitch / 22.5) Sound.play('entity.bobber.throw', .6) + display(meta) os.sleep(0.1) elseif meta.motionY < -0.5 then -- falling fast modules.launch(0, 270, -meta.motionY + 1) Sound.play('entity.bat.takeoff') + display(meta) os.sleep(0) else + display(meta) os.sleep(0.1) end @@ -53,6 +81,7 @@ local function run() os.sleep(0) else + clearDisplay() launchCounter = 0 os.sleep(0.4) end @@ -76,4 +105,4 @@ parallel.waitForAny( print('Waiting for 5 seconds before restarting') os.sleep(5) end - end) + end) \ No newline at end of file