1.7.10 compatibility

This commit is contained in:
kepler155c
2018-02-25 07:05:19 -05:00
parent 2bf2e41ee6
commit 959058b5fb
4 changed files with 2905 additions and 39 deletions

View File

@@ -208,6 +208,9 @@ function Craft.getResourceList(inRecipe, items, inCount)
elseif not summedItem.recipe then elseif not summedItem.recipe then
summedItem.need = 1 summedItem.need = 1
need = 1 need = 1
else
summedItem.need = 1
need = 1
end end
else else
summedItem.total = summedItem.total + total summedItem.total = summedItem.total + total

View File

@@ -207,9 +207,11 @@ local function getItems()
end end
local function isMachineEmpty(machine, item) local function isMachineEmpty(machine, item)
local list = { true }
pcall(function() -- fails randomly in 1.7x
local side = turtle.getAction(machine.dir).side local side = turtle.getAction(machine.dir).side
local methods = Util.transpose(Peripheral.getMethods(side)) local methods = Util.transpose(Peripheral.getMethods(side))
local list = { true }
if methods.getAllStacks then -- 1.7x if methods.getAllStacks then -- 1.7x
list = Peripheral.call(side, 'getAllStacks', false) list = Peripheral.call(side, 'getAllStacks', false)
@@ -228,6 +230,7 @@ local function isMachineEmpty(machine, item)
if tonumber(machine.ignoreSlot) then if tonumber(machine.ignoreSlot) then
list[tonumber(machine.ignoreSlot)] = nil list[tonumber(machine.ignoreSlot)] = nil
end end
end)
if Util.empty(list) then if Util.empty(list) then
return true return true

View File

@@ -34,16 +34,17 @@
from the restocking inventory into the main inventory. from the restocking inventory into the main inventory.
Configuration: Configuration:
Note: computerFacing and inventory are required. All others are optional.
valid sides: valid sides:
top, bottom, left, right, front, back top, bottom, left, right, front, back
valid directions: valid directions:
up, down, north, south, east, west up, down, north, south, east, west
Required:
computerFacing : direction turtle is facing computerFacing : direction turtle is facing
inventory : side for the main inventory (can be the same as the controller) inventory : side for the main inventory (can be the same as the controller)
Optional:
craftingChest : side for the chest used for crafting craftingChest : side for the chest used for crafting
controller : side for AE / RS block controller : side for AE / RS block
stock : side for restocking inventory stock : side for restocking inventory
@@ -261,18 +262,6 @@ end
-- Craft -- Craft
local function craftItem(recipe, items, originalItem, craftList, count) local function craftItem(recipe, items, originalItem, craftList, count)
if craftingPaused or not canCraft then
return 0
end
if not isGridClear() then
if not clearGrid() then
originalItem.status = 'Grid obstructed'
originalItem.statusCode = STATUS_ERROR
return 0
end
end
local missing = { } local missing = { }
local toCraft = Craft.getCraftableAmount(recipe, count, items, missing) local toCraft = Craft.getCraftableAmount(recipe, count, items, missing)
if missing.name then if missing.name then
@@ -386,6 +375,28 @@ local function forceCraftItem(inRecipe, items, originalItem, craftList, inCount)
return count return count
end end
local function craft(recipe, items, item, craftList)
item.status = nil
item.statusCode = nil
item.crafted = 0
if craftingPaused or not canCraft then
return
end
if not clearGrid() then
item.status = 'Grid obstructed'
item.statusCode = STATUS_ERROR
return
end
if item.forceCrafting then
item.crafted = forceCraftItem(recipe, items, item, craftList, item.count)
else
item.crafted = craftItem(recipe, items, item, craftList, item.count)
end
end
local function craftItems(craftList, allItems) local function craftItems(craftList, allItems)
-- turtle crafting -- turtle crafting
if canCraft then if canCraft then
@@ -393,13 +404,7 @@ local function craftItems(craftList, allItems)
local item = craftList[key] local item = craftList[key]
local recipe = Craft.recipes[key] local recipe = Craft.recipes[key]
if recipe then if recipe then
item.status = nil craft(recipe, allItems, item, craftList)
item.statusCode = nil
if item.forceCrafting then
item.crafted = forceCraftItem(recipe, allItems, item, craftList, item.count)
else
item.crafted = craftItem(recipe, allItems, item, craftList, item.count)
end
allItems = listItems() -- refresh counts allItems = listItems() -- refresh counts
if not allItems then if not allItems then
break break

File diff suppressed because it is too large Load Diff