1.7.10 compatibility
This commit is contained in:
@@ -17,7 +17,7 @@ function ChestAdapter:init(args)
|
|||||||
chest = Peripheral.getByMethod('list') or Peripheral.getByMethod('listAvailableItems')
|
chest = Peripheral.getByMethod('list') or Peripheral.getByMethod('listAvailableItems')
|
||||||
else
|
else
|
||||||
chest = Peripheral.getBySide(self.side)
|
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
|
chest = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -114,12 +114,13 @@ local config = {
|
|||||||
monitor = 'type/monitor',
|
monitor = 'type/monitor',
|
||||||
}
|
}
|
||||||
|
|
||||||
Config.loadWithCheck('inventoryManager', config)
|
Config.loadWithCheck('inventtoryManager', config)
|
||||||
|
|
||||||
local controllerAdapter = ControllerAdapter.wrap({ side = config.controller, facing = config.computerFacing })
|
local controllerAdapter = ControllerAdapter.wrap({ side = config.controller, facing = config.computerFacing })
|
||||||
local inventoryAdapter = InventoryAdapter.wrap({ side = config.inventory, facing = config.computerFacing })
|
local inventoryAdapter = InventoryAdapter.wrap({ side = config.inventory, facing = config.computerFacing })
|
||||||
local stockAdapter = InventoryAdapter.wrap({ side = config.stock, facing = config.computerFacing })
|
local stockAdapter = InventoryAdapter.wrap({ side = config.stock, facing = config.computerFacing })
|
||||||
local turtleChestAdapter = InventoryAdapter.wrap({ side = config.craftingChest, facing = config.computerFacing })
|
local turtleChestAdapter = InventoryAdapter.wrap({ side = config.craftingChest, facing = config.computerFacing })
|
||||||
|
local modem = device.modem
|
||||||
local duckAntenna
|
local duckAntenna
|
||||||
|
|
||||||
if not inventoryAdapter then
|
if not inventoryAdapter then
|
||||||
@@ -434,15 +435,25 @@ local function craftItems(craftList, allItems)
|
|||||||
end
|
end
|
||||||
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
|
-- controller
|
||||||
if controllerAdapter then
|
if controllerAdapter then
|
||||||
for key,item in pairs(craftList) do
|
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
|
if controllerAdapter:isCrafting(item) then
|
||||||
item.status = '(crafting)'
|
item.status = '(crafting)'
|
||||||
item.statusCode = STATUS_INFO
|
item.statusCode = STATUS_INFO
|
||||||
else
|
else
|
||||||
local count = item.count
|
local count = item.count
|
||||||
|
item.crafted = 0
|
||||||
while count >= 1 do -- try to request smaller quantities until successful
|
while count >= 1 do -- try to request smaller quantities until successful
|
||||||
local s = pcall(function()
|
local s = pcall(function()
|
||||||
item.status = '(no recipe)'
|
item.status = '(no recipe)'
|
||||||
@@ -454,6 +465,7 @@ local function craftItems(craftList, allItems)
|
|||||||
end
|
end
|
||||||
item.status = '(crafting)'
|
item.status = '(crafting)'
|
||||||
item.statusCode = STATUS_INFO
|
item.statusCode = STATUS_INFO
|
||||||
|
item.crafted = count
|
||||||
end)
|
end)
|
||||||
if s then
|
if s then
|
||||||
break -- successfully requested crafting
|
break -- successfully requested crafting
|
||||||
@@ -957,7 +969,7 @@ function listingPage.grid:getRowTextColor(row, selected)
|
|||||||
if row.is_craftable then
|
if row.is_craftable then
|
||||||
return colors.yellow
|
return colors.yellow
|
||||||
end
|
end
|
||||||
if row.has_recipe then
|
if canCraft and row.has_recipe then
|
||||||
return colors.cyan
|
return colors.cyan
|
||||||
end
|
end
|
||||||
return UI.Grid:getRowTextColor(row, selected)
|
return UI.Grid:getRowTextColor(row, selected)
|
||||||
@@ -1010,7 +1022,8 @@ function listingPage:eventHandler(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
elseif event.type == 'craft' or event.type == 'grid_select_right' then
|
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())
|
UI:setPage('craft', self.grid:getSelected())
|
||||||
else
|
else
|
||||||
self.notification:error('No recipe defined')
|
self.notification:error('No recipe defined')
|
||||||
@@ -1332,11 +1345,15 @@ function craftPage.wizard.pages.resources:enable()
|
|||||||
local items = listItems()
|
local items = listItems()
|
||||||
local count = tonumber(self.parent.quantity.count.value)
|
local count = tonumber(self.parent.quantity.count.value)
|
||||||
local recipe = Craft.findRecipe(craftPage.item)
|
local recipe = Craft.findRecipe(craftPage.item)
|
||||||
local ingredients = Craft.getResourceList4(recipe, items, count)
|
if recipe then
|
||||||
for _,v in pairs(ingredients) do
|
local ingredients = Craft.getResourceList4(recipe, items, count)
|
||||||
v.displayName = itemDB:getName(v)
|
for _,v in pairs(ingredients) do
|
||||||
|
v.displayName = itemDB:getName(v)
|
||||||
|
end
|
||||||
|
self.grid:setValues(ingredients)
|
||||||
|
else
|
||||||
|
self.grid:setValues({ })
|
||||||
end
|
end
|
||||||
self.grid:setValues(ingredients)
|
|
||||||
return UI.Window.enable(self)
|
return UI.Window.enable(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user