diff --git a/farms/farmer.lua b/farms/farmer.lua index 93ff888..273edf9 100644 --- a/farms/farmer.lua +++ b/farms/farmer.lua @@ -9,8 +9,15 @@ local os = _G.os local peripheral = _G.peripheral local turtle = _G.turtle -local CONFIG_FILE = 'usr/config/farmer' +local CONFIG_FILE = 'usr/config/farmer' 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 turtle.equip('right', 'plethora:module:2') and device['plethora:scanner'] or @@ -148,6 +155,22 @@ local function harvest(blocks) dropped = true 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 elseif b.action == 'smash' then diff --git a/milo/plugins/remote/autostore.lua b/milo/plugins/remote/autostore.lua index bb2d05e..e044bd6 100644 --- a/milo/plugins/remote/autostore.lua +++ b/milo/plugins/remote/autostore.lua @@ -24,7 +24,7 @@ local page = UI.Page { y = 2, inventory = UI.Window { tabTitle = 'Inventory', - grid = UI.Grid { + grid = UI.ScrollingGrid { y = 2, ey = -2, columns = { { heading = 'Name', key = 'displayName' }, @@ -34,7 +34,7 @@ local page = UI.Page { }, autostore = UI.Window { tabTitle = 'Sending', - grid = UI.Grid { + grid = UI.ScrollingGrid { y = 2, ey = -2, columns = { { heading = 'Name', key = 'displayName' }, @@ -73,21 +73,7 @@ function page.tabs.inventory.grid:getRowTextColor(row) if context.state.autostore[row.key] then return colors.yellow end - return UI.Grid.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) + return UI.ScrollingGrid.getRowTextColor(self, row) end function page.tabs.inventory:eventHandler(event) @@ -104,6 +90,20 @@ function page.tabs.inventory:eventHandler(event) 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) if event.type == 'grid_select' then local key = itemDB:makeKey(event.selected)