small updates + elytraFly hud

This commit is contained in:
kepler155c@gmail.com
2019-02-28 22:34:02 -05:00
parent 389038dc77
commit 838b7d5d69
6 changed files with 34 additions and 15 deletions

View File

@@ -1,5 +1,3 @@
_G.requireInjector(_ENV)
local Point = require('point')
local Util = require('util')

View File

@@ -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

View File

@@ -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()

View File

@@ -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

View File

@@ -1 +0,0 @@
-- moved

View File

@@ -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