app tweaks

This commit is contained in:
kepler155c@gmail.com
2019-04-25 14:43:55 -04:00
parent c486301116
commit b03b0d366b
6 changed files with 103 additions and 19 deletions

View File

@@ -1134,7 +1134,6 @@ while bRunning do
action = keyMapping.char
param = ie.ch
else
_debug(ie.code)
action = keyMapping[ie.code]
end
end

View File

@@ -115,7 +115,7 @@ Needs work
run = "multiMiner.lua",
},
[ "hexedit" ] = {
title = "hexEdit",
title = "HexEdit",
category = "Apps",
requires = "advancedComputer",
icon = "  dfŸfdŒdf›f5Œ5f›\

View File

@@ -171,11 +171,6 @@ local function run(member, point)
turtle.set({
movementStrategy = 'goto',
digPolicy = 'blacklist',
blacklist = {
'turtle',
'chest',
'shulker',
},
})
end
@@ -252,11 +247,17 @@ local function run(member, point)
while not turtle.go(Point.above(spt)) do
os.sleep(.5)
end
turtle.set({ digPolicy = 'dig' })
turtle.go(spt)
if turtle.selectSlotWithQuantity(0) then
turtle.set({ digPolicy = 'dig' })
end
while not turtle.go(spt) do
os.sleep(.5)
end
else
turtle.gotoY(spt.y)
turtle.go(spt)
while not turtle.go(spt) do
os.sleep(.5)
end
end
end)

70
ignore/Vision.lua Normal file
View File

@@ -0,0 +1,70 @@
local Event = require('event')
local Point = require('point')
local Proxy = require('proxy')
local Util = require('util')
local device = _G.device
local network = _G.network
local glasses = device['plethora:glasses'] or error('Overlay glasses are required')
local id = tonumber(({...})[1]) or
error('Syntax: Vision <id>')
local blacklist = {
[ 'minecraft:air'] = true,
}
local turtle, socket = Proxy.create(id, 'device/plethora:scanner')
if not turtle then
error('nope')
end
local current
local projecting = { }
local canvas = glasses.canvas3d().create()
local function displayBlocks(scanned)
print('redrawing')
local blocks = { }
for _, b in pairs(scanned) do
-- track block's world position
b.id = table.concat({ b.x, b.y, b.z }, ':')
blocks[b.id] = b
end
for _, b in pairs(blocks) do
if not projecting[b.id] then
projecting[b.id] = b
pcall(function()
b.box = canvas.addItem({ b.x / 40, b.y / 40 - .25, b.z / 40 }, b.name, b.damage, .025)
end)
-- b.box.setDepthTested(false)
end
end
for _, b in pairs(projecting) do
if b.box and not blocks[b.id] then
b.box.remove()
projecting[b.id] = nil
end
end
end
Event.onInterval(1, function()
local t = network[id]
--if t and t.point and (not current or not Point.same(t.point, current)) then
-- current = t.point
local scanned = turtle.scan(blacklist)
if scanned then
displayBlocks(Util.filter(turtle.scan(), function(b)
if not blacklist[b.name] then
return true
end
end))
end
--end
end)
Event.pullEvents()
canvas:clear()
socket:close()

View File

@@ -14,14 +14,16 @@ function LimitTask:cycle(context)
if res.limit then
local items, count = Milo:getMatches(itemDB:splitKey(key), res)
if count > res.limit then
local amount = count - res.limit
local total = count - res.limit
for _, item in pairs(items) do
amount = amount - context.storage:export(
local amount = context.storage:export(
trashcan,
nil,
math.min(amount, item.count),
math.min(total, item.count),
item)
if amount <= 0 then
total = total - amount
-- amount == 0 means that trashcan is full
if amount <= 0 or total <= 0 then
break
end
end

View File

@@ -19,20 +19,32 @@ local turtle = _G.turtle
fs.mount('sys/apps/system/turtle.lua', 'linkfs', 'packages/turtle/system/turtle.lua')
-- provide a turtle function for scanning
function turtle.scan(blocks)
function turtle.scan(whitelist, blacklist)
local pt = turtle.point
local scanner = device['plethora:scanner'] or error('Scanner not equipped')
if not blocks then
return Util.each(scanner:scan(), function(b)
if not whitelist and not blacklist then
return Util.each(scanner.scan(), function(b)
b.x = pt.x + b.x
b.y = pt.y + b.y
b.z = pt.z + b.z
end)
end
return Util.filter(scanner:scan(), function(b)
if blocks[b.name] then
if whitelist then
return Util.filter(scanner.scan(), function(b)
if whitelist[b.name] then
b.x = pt.x + b.x
b.y = pt.y + b.y
b.z = pt.z + b.z
return true
end
end)
end
return Util.filter(scanner.scan(), function(b)
if not blacklist[b.name] then
b.x = pt.x + b.x
b.y = pt.y + b.y
b.z = pt.z + b.z