cleanup + games

This commit is contained in:
kepler155c@gmail.com
2019-01-17 22:01:40 -05:00
parent 6416e67130
commit ef5eab65f9
8 changed files with 422 additions and 61 deletions

View File

@@ -28,7 +28,7 @@ local function locate()
end
local spt = GPS.getPoint() or error('GPS failure')
local chestPoint -- location of chest
local chestPoint -- location of chest
local blockTypes = { } -- blocks types requested to mine
local turtles = { } -- active turtles
local pool = { } -- all turtles
@@ -39,7 +39,7 @@ local function hijackTurtle(remoteId)
local socket, msg = Socket.connect(remoteId, 188)
if not socket then
printError(remoteId)
_G.printError(remoteId)
error(msg)
end
@@ -72,7 +72,7 @@ end
local function run(member, point)
Event.addRoutine(function()
--local _, m = pcall(function()
local _, m = pcall(function()
member.active = true
local turtle = hijackTurtle(member.id)
@@ -159,6 +159,8 @@ local function run(member, point)
until member.abort
end
emptySlots(blockTypes, Point.above(turtle.getPoint()))
if chestPoint then
dropOff()
while not turtle._goto(Point.above(spt)) do
@@ -170,9 +172,9 @@ local function run(member, point)
turtle.gotoY(spt.y)
turtle._goto(spt)
end
--end)
end)
turtles[member.id] = nil
--member.status = m
member.status = m
member.active = false
end)
end
@@ -233,7 +235,6 @@ end
function page:scan()
local gpt = GPS.getPoint()
if not gpt then
_debug('gps failed')
return
end
local rawBlocks = scanner:scan()
@@ -384,6 +385,7 @@ end)
Event.onTimeout(.5, function()
page:scan()
blocksTab.grid:setValues(page.totals)
page:sync()
end)
UI:setPage(page)

View File

@@ -20,6 +20,7 @@ local fs = _G.fs
local os = _G.os
local peripheral = _G.peripheral
local read = _G.read
local term = _G.term
local turtle = _G.turtle
UI:configure('scanningMiner', ...)

View File

@@ -170,7 +170,7 @@ local function addTrash()
local slots = turtle.getFilledSlots()
for _,slot in pairs(slots) do
trash[slot.iddmg] = true
trash[slot.key] = true
end
trash['minecraft:bucket:0'] = nil
@@ -300,11 +300,11 @@ local function normalChestUnload()
end
local slots = turtle.getFilledSlots()
for _,slot in pairs(slots) do
if not trash[slot.iddmg] and
slot.iddmg ~= 'minecraft:bucket:0' and
slot.id ~= 'minecraft:diamond_pickaxe' and
slot.id ~= 'cctweaks:toolHost' then
if slot.id ~= options.fortunePick.value then
if not trash[slot.key] and
slot.key ~= 'minecraft:bucket:0' and
slot.name ~= 'minecraft:diamond_pickaxe' and
slot.name ~= 'cctweaks:toolHost' then
if slot.name ~= options.fortunePick.value then
turtle.select(slot.index)
turtle.dropUp(64)
end
@@ -325,7 +325,7 @@ local function ejectTrash()
local cobbleSlotCount = 0
turtle.eachFilledSlot(function(slot)
if slot.iddmg == 'minecraft:cobblestone:0' then
if slot.key == 'minecraft:cobblestone:0' then
if cobbleSlotCount == 0 and slot.count > 36 then
turtle.select(slot.index)
turtle.dropDown(slot.count - 36)
@@ -333,9 +333,9 @@ local function ejectTrash()
cobbleSlotCount = cobbleSlotCount + 1
end
if trash[slot.iddmg] then
if trash[slot.key] then
-- retain 1 slot with cobble in order to indicate active mining
if slot.iddmg ~= 'minecraft:cobblestone:0' or cobbleSlotCount > 1 then
if slot.key ~= 'minecraft:cobblestone:0' or cobbleSlotCount > 1 then
turtle.select(slot.index)
turtle.dropDown(64)
end
@@ -603,7 +603,7 @@ if options.fortunePick.value then
if not turtle.getSlot('cctweaks:toolHost:0') then
error('CCTweaks tool host not found')
end
trash[s.iddmg] = nil
trash[s.key] = nil
trash['minecraft:diamond_pickaxe:0'] = nil
trash['cctweaks:toolHost:0'] = nil
end