farmer autorefuel
This commit is contained in:
@@ -9,8 +9,15 @@ local os = _G.os
|
|||||||
local peripheral = _G.peripheral
|
local peripheral = _G.peripheral
|
||||||
local turtle = _G.turtle
|
local turtle = _G.turtle
|
||||||
|
|
||||||
local CONFIG_FILE = 'usr/config/farmer'
|
local CONFIG_FILE = 'usr/config/farmer'
|
||||||
local STARTUP_FILE = 'usr/autorun/farmer.lua'
|
local STARTUP_FILE = 'usr/autorun/farmer.lua'
|
||||||
|
local MIN_FUEL = 2500
|
||||||
|
|
||||||
|
local FUEL = Util.transpose {
|
||||||
|
'minecraft:coal:0',
|
||||||
|
'minecraft:coal:1',
|
||||||
|
'minecraft:blaze_rod:0',
|
||||||
|
}
|
||||||
|
|
||||||
local scanner = device['plethora:scanner'] or
|
local scanner = device['plethora:scanner'] or
|
||||||
turtle.equip('right', 'plethora:module:2') and device['plethora:scanner'] or
|
turtle.equip('right', 'plethora:module:2') and device['plethora:scanner'] or
|
||||||
@@ -148,6 +155,22 @@ local function harvest(blocks)
|
|||||||
|
|
||||||
dropped = true
|
dropped = true
|
||||||
turtle.condense()
|
turtle.condense()
|
||||||
|
|
||||||
|
if turtle.getFuelLevel() < MIN_FUEL then
|
||||||
|
local inv = peripheral.wrap('bottom')
|
||||||
|
if inv and inv.list then
|
||||||
|
for k, v in pairs(inv.list()) do
|
||||||
|
if FUEL[table.concat({ v.name, v.damage }, ':')] then
|
||||||
|
local count = inv.pushItems('up', k, v.count)
|
||||||
|
if count > 0 then
|
||||||
|
turtle.refuel(v.name, v.count)
|
||||||
|
print('Fuel: ' .. turtle.getFuelLevel())
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif b.action == 'smash' then
|
elseif b.action == 'smash' then
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ local page = UI.Page {
|
|||||||
y = 2,
|
y = 2,
|
||||||
inventory = UI.Window {
|
inventory = UI.Window {
|
||||||
tabTitle = 'Inventory',
|
tabTitle = 'Inventory',
|
||||||
grid = UI.Grid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2, ey = -2,
|
y = 2, ey = -2,
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Name', key = 'displayName' },
|
{ heading = 'Name', key = 'displayName' },
|
||||||
@@ -34,7 +34,7 @@ local page = UI.Page {
|
|||||||
},
|
},
|
||||||
autostore = UI.Window {
|
autostore = UI.Window {
|
||||||
tabTitle = 'Sending',
|
tabTitle = 'Sending',
|
||||||
grid = UI.Grid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2, ey = -2,
|
y = 2, ey = -2,
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Name', key = 'displayName' },
|
{ heading = 'Name', key = 'displayName' },
|
||||||
@@ -73,21 +73,7 @@ function page.tabs.inventory.grid:getRowTextColor(row)
|
|||||||
if context.state.autostore[row.key] then
|
if context.state.autostore[row.key] then
|
||||||
return colors.yellow
|
return colors.yellow
|
||||||
end
|
end
|
||||||
return UI.Grid.getRowTextColor(self, row)
|
return UI.ScrollingGrid.getRowTextColor(self, row)
|
||||||
end
|
|
||||||
|
|
||||||
function page.tabs.autostore:enable()
|
|
||||||
local list = { }
|
|
||||||
|
|
||||||
for key in pairs(context.state.autostore or { }) do
|
|
||||||
local cItem = itemDB:get(key)
|
|
||||||
if cItem then
|
|
||||||
table.insert(list, cItem)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.grid:setValues(list)
|
|
||||||
|
|
||||||
return UI.Window.enable(self)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function page.tabs.inventory:eventHandler(event)
|
function page.tabs.inventory:eventHandler(event)
|
||||||
@@ -104,6 +90,20 @@ function page.tabs.inventory:eventHandler(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function page.tabs.autostore:enable()
|
||||||
|
local list = { }
|
||||||
|
|
||||||
|
for key in pairs(context.state.autostore or { }) do
|
||||||
|
local cItem = itemDB:get(key)
|
||||||
|
if cItem then
|
||||||
|
table.insert(list, cItem)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.grid:setValues(list)
|
||||||
|
|
||||||
|
return UI.Window.enable(self)
|
||||||
|
end
|
||||||
|
|
||||||
function page.tabs.autostore:eventHandler(event)
|
function page.tabs.autostore:eventHandler(event)
|
||||||
if event.type == 'grid_select' then
|
if event.type == 'grid_select' then
|
||||||
local key = itemDB:makeKey(event.selected)
|
local key = itemDB:makeKey(event.selected)
|
||||||
|
|||||||
Reference in New Issue
Block a user