From c1f6ac11e101fb6a5c94ae2afd437b91858939e7 Mon Sep 17 00:00:00 2001 From: kepler155c Date: Sun, 11 Mar 2018 17:24:12 -0400 Subject: [PATCH] 1.7.10 compatibility --- apis/chestAdapter18.lua | 2 +- apps/chestManager.lua | 33 +++++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/apis/chestAdapter18.lua b/apis/chestAdapter18.lua index 2ba5b87..a19a6d1 100644 --- a/apis/chestAdapter18.lua +++ b/apis/chestAdapter18.lua @@ -17,7 +17,7 @@ function ChestAdapter:init(args) chest = Peripheral.getByMethod('list') or Peripheral.getByMethod('listAvailableItems') else chest = Peripheral.getBySide(self.side) - if chest and not chest.list then + if chest and not chest.list and not chest.listAvailableItems then chest = nil end end diff --git a/apps/chestManager.lua b/apps/chestManager.lua index 8f055a3..414d4c2 100644 --- a/apps/chestManager.lua +++ b/apps/chestManager.lua @@ -114,12 +114,13 @@ local config = { monitor = 'type/monitor', } -Config.loadWithCheck('inventoryManager', config) +Config.loadWithCheck('inventtoryManager', config) local controllerAdapter = ControllerAdapter.wrap({ side = config.controller, facing = config.computerFacing }) local inventoryAdapter = InventoryAdapter.wrap({ side = config.inventory, facing = config.computerFacing }) local stockAdapter = InventoryAdapter.wrap({ side = config.stock, facing = config.computerFacing }) local turtleChestAdapter = InventoryAdapter.wrap({ side = config.craftingChest, facing = config.computerFacing }) +local modem = device.modem local duckAntenna if not inventoryAdapter then @@ -434,15 +435,25 @@ local function craftItems(craftList, allItems) end end + -- remote processing + if modem then + for key,item in pairs(craftList) do + if Craft.recipes[key] and item.crafted < item.count then + + end + end + end + -- controller if controllerAdapter then for key,item in pairs(craftList) do - if not Craft.recipes[key] and not item.rsControl then + if not canCraft or not Craft.recipes[key] and not item.rsControl then if controllerAdapter:isCrafting(item) then item.status = '(crafting)' item.statusCode = STATUS_INFO else local count = item.count + item.crafted = 0 while count >= 1 do -- try to request smaller quantities until successful local s = pcall(function() item.status = '(no recipe)' @@ -454,6 +465,7 @@ local function craftItems(craftList, allItems) end item.status = '(crafting)' item.statusCode = STATUS_INFO + item.crafted = count end) if s then break -- successfully requested crafting @@ -957,7 +969,7 @@ function listingPage.grid:getRowTextColor(row, selected) if row.is_craftable then return colors.yellow end - if row.has_recipe then + if canCraft and row.has_recipe then return colors.cyan end return UI.Grid:getRowTextColor(row, selected) @@ -1010,7 +1022,8 @@ function listingPage:eventHandler(event) end elseif event.type == 'craft' or event.type == 'grid_select_right' then - if Craft.findRecipe(self.grid:getSelected()) then + local item = self.grid:getSelected() + if Craft.findRecipe(item) or item.has_recipe then UI:setPage('craft', self.grid:getSelected()) else self.notification:error('No recipe defined') @@ -1332,11 +1345,15 @@ function craftPage.wizard.pages.resources:enable() local items = listItems() local count = tonumber(self.parent.quantity.count.value) local recipe = Craft.findRecipe(craftPage.item) - local ingredients = Craft.getResourceList4(recipe, items, count) - for _,v in pairs(ingredients) do - v.displayName = itemDB:getName(v) + if recipe then + local ingredients = Craft.getResourceList4(recipe, items, count) + for _,v in pairs(ingredients) do + v.displayName = itemDB:getName(v) + end + self.grid:setValues(ingredients) + else + self.grid:setValues({ }) end - self.grid:setValues(ingredients) return UI.Window.enable(self) end