miner improvements
This commit is contained in:
@@ -60,7 +60,7 @@ end
|
|||||||
|
|
||||||
function page:applyFilter()
|
function page:applyFilter()
|
||||||
local t = Util.filter(context.storage.nodes, function(v)
|
local t = Util.filter(context.storage.nodes, function(v)
|
||||||
return v.mtype ~= 'hidden' and device[v.name]
|
return v.mtype == 'ignore' and device[v.name]
|
||||||
end)
|
end)
|
||||||
|
|
||||||
self.grid:setValues(t)
|
self.grid:setValues(t)
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ local page = UI.Page {
|
|||||||
buttons = {
|
buttons = {
|
||||||
--{ text = 'Mine', event = 'mine' },
|
--{ text = 'Mine', event = 'mine' },
|
||||||
{ text = 'Ignore', event = 'ignore' },
|
{ text = 'Ignore', event = 'ignore' },
|
||||||
{ text = 'Ignore All', event = 'ignore_all' },
|
{ text = 'Abort', event = 'abort', x = -8 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
grid = UI.Grid {
|
grid = UI.Grid {
|
||||||
@@ -121,17 +121,17 @@ function page:eventHandler(event)
|
|||||||
dictionary:write()
|
dictionary:write()
|
||||||
|
|
||||||
elseif event.type == 'ignore' then
|
elseif event.type == 'ignore' then
|
||||||
dictionary:ignore(t.name, t.damage)
|
|
||||||
dictionary:write()
|
|
||||||
self.grid:draw()
|
|
||||||
|
|
||||||
elseif event.type == 'ignore_all' then
|
|
||||||
dictionary:ignore(t.name)
|
dictionary:ignore(t.name)
|
||||||
dictionary:write()
|
dictionary:write()
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if event.type == 'quit' then
|
|
||||||
|
if event.type == 'abort' then
|
||||||
|
turtle.abort(true)
|
||||||
|
|
||||||
|
elseif event.type == 'quit' then
|
||||||
turtle.abort(true)
|
turtle.abort(true)
|
||||||
end
|
end
|
||||||
UI.Page.eventHandler(self, event)
|
UI.Page.eventHandler(self, event)
|
||||||
@@ -333,6 +333,7 @@ local function scan()
|
|||||||
equip('left', 'plethora:module')
|
equip('left', 'plethora:module')
|
||||||
local blocks = peripheral.call('left', 'scan')
|
local blocks = peripheral.call('left', 'scan')
|
||||||
equip('left', 'minecraft:diamond_pickaxe')
|
equip('left', 'minecraft:diamond_pickaxe')
|
||||||
|
local throttle = Util.throttle()
|
||||||
|
|
||||||
local bedrock = -256
|
local bedrock = -256
|
||||||
local counts = { }
|
local counts = { }
|
||||||
@@ -344,6 +345,7 @@ local function scan()
|
|||||||
b.x = b.x + turtle.point.x
|
b.x = b.x + turtle.point.x
|
||||||
b.y = b.y + turtle.point.y
|
b.y = b.y + turtle.point.y
|
||||||
b.z = b.z + turtle.point.z
|
b.z = b.z + turtle.point.z
|
||||||
|
throttle()
|
||||||
|
|
||||||
if b.name == 'minecraft:bedrock' then
|
if b.name == 'minecraft:bedrock' then
|
||||||
if b.y > bedrock then
|
if b.y > bedrock then
|
||||||
@@ -353,20 +355,18 @@ local function scan()
|
|||||||
end
|
end
|
||||||
|
|
||||||
Util.filterInplace(blocks, function(b)
|
Util.filterInplace(blocks, function(b)
|
||||||
if b.y >= 0 or
|
throttle()
|
||||||
(b.action == 'liquid_fuel' and b.y <= bedrock) then
|
if b.y >= bedrock then
|
||||||
return false
|
|
||||||
|
|
||||||
elseif b.action == 'liquid_fuel' and b.damage > 0 then
|
|
||||||
return false
|
|
||||||
|
|
||||||
elseif b.y >= bedrock then
|
|
||||||
b.action = dictionary:get(b.name, b.metadata) or 'mine'
|
b.action = dictionary:get(b.name, b.metadata) or 'mine'
|
||||||
|
|
||||||
if ignores[b.action] then
|
if ignores[b.action] then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if b.action == 'liquid_fuel' and (b.y <= bedrock or b.metadata > 0) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local key = b.name .. ':' .. b.metadata
|
local key = b.name .. ':' .. b.metadata
|
||||||
if not counts[key] then
|
if not counts[key] then
|
||||||
counts[key] = {
|
counts[key] = {
|
||||||
@@ -411,6 +411,8 @@ local function scan()
|
|||||||
-- Get the action again in case the user has ignored via UI
|
-- Get the action again in case the user has ignored via UI
|
||||||
b.action = dictionary:get(b.name, b.metadata) or 'mine'
|
b.action = dictionary:get(b.name, b.metadata) or 'mine'
|
||||||
if b.action == 'suck' or b.action == 'mine' then
|
if b.action == 'suck' or b.action == 'mine' then
|
||||||
|
status('mining: ' .. table.concat({ b.x, b.y, b.z }, ', '))
|
||||||
|
|
||||||
if b.action == 'suck' then
|
if b.action == 'suck' then
|
||||||
local pt = turtle.moveAgainst(b)
|
local pt = turtle.moveAgainst(b)
|
||||||
collectDrops(turtle.getAction(pt.direction).suck)
|
collectDrops(turtle.getAction(pt.direction).suck)
|
||||||
@@ -609,6 +611,7 @@ Event.addRoutine(function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
status(success and 'finished' or turtle.isAborted() and 'aborting' or 'error')
|
status(success and 'finished' or turtle.isAborted() and 'aborting' or 'error')
|
||||||
|
turtle.gotoY(0)
|
||||||
if turtle._goto({ x = 0, y = 0, z = 0 }) then
|
if turtle._goto({ x = 0, y = 0, z = 0 }) then
|
||||||
unload()
|
unload()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user