plethora import/export support + introspection module

This commit is contained in:
kepler155c
2018-03-29 05:04:34 -04:00
parent 55f49a1127
commit 08bc0d578e
3 changed files with 33 additions and 13 deletions

View File

@@ -14,10 +14,11 @@ function ChestAdapter:init(args)
local chest local chest
if not self.side then if not self.side then
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 and not chest.listAvailableItems then if chest and not chest.list then -- and not chest.listAvailableItems then
chest = nil chest = nil
end end
end end

View File

@@ -14,10 +14,10 @@ function RefinedAdapter:init(args)
local controller local controller
if not self.side then if not self.side then
controller = Peripheral.getByType('refinedstorage:controller') controller = Peripheral.getByMethod('listAvailableItems')
else else
controller = Peripheral.getBySide(self.side) controller = Peripheral.getBySide(self.side)
if controller and not controller.getCraftingTasks then if controller and not controller.listAvailableItems then
controller = nil controller = nil
end end
end end
@@ -131,7 +131,12 @@ function RefinedAdapter:provide(item, qty, slot, direction)
end) end)
end end
function RefinedAdapter:insert() function RefinedAdapter:extract(slot, qty, toSlot)
self.pushItems(self.direction, slot, qty, toSlot)
end
function RefinedAdapter:insert(slot, qty, toSlot)
self.pullItems(self.direction, slot, qty, toSlot)
end end
return RefinedAdapter return RefinedAdapter

View File

@@ -24,7 +24,11 @@
2. Requires a vanilla chest beside the turtle with the "craftingChest" 2. Requires a vanilla chest beside the turtle with the "craftingChest"
configuration variable defined. configuration variable defined.
-- or -- -- or --
If using MC 1.7x, you can equip the turtle with a duck antenna. If using MC 1.7x, you can equip the turtle with a duck antenna and
set the duckAntenna configuration value to true.
-- or --
If plethora mod is available, equip the turtle with an introspection
module.
Controller (optional): Controller (optional):
Provides the ability to request crafting from AE / RS Provides the ability to request crafting from AE / RS
@@ -38,7 +42,7 @@
Refined Storage Refined Storage
In versions 1.8x, inventory access works depending upon version. In versions 1.8x, inventory access works depending upon version.
Turtle/computer must be touching controller for inventory access. If only Turtle/computer must be touching an interface for inventory access. If only
requesting crafting, the controller must be either be touching or connected requesting crafting, the controller must be either be touching or connected
via CC cables. via CC cables.
@@ -66,6 +70,7 @@
craftingChest : side for the chest used for crafting craftingChest : side for the chest used for crafting
controller : side for AE cable/interface or RS controller controller : side for AE cable/interface or RS controller
stock : side for restocking inventory stock : side for restocking inventory
duckAntenna : true/false if the 1.7 openperipherals duck antenna is equipped
trashDirection : direction of trash block (trashcan/inventory/etc) in trashDirection : direction of trash block (trashcan/inventory/etc) in
relationship to the main inventory. This block does not relationship to the main inventory. This block does not
need to touch the turtle, only the main inventory block. need to touch the turtle, only the main inventory block.
@@ -116,11 +121,12 @@ local config = {
Config.loadWithCheck('inventoryManager', config) Config.loadWithCheck('inventoryManager', 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 modem = device.modem
local introspectionModule = device['plethora:introspection']
local duckAntenna local duckAntenna
if not inventoryAdapter then if not inventoryAdapter then
@@ -148,7 +154,7 @@ local RECIPES_FILE = 'usr/config/recipes.db'
local craftingPaused = false local craftingPaused = false
local canCraft = not not (turtle and turtle.craft) local canCraft = not not (turtle and turtle.craft)
local canLearn = not not (canCraft and (duckAntenna or turtleChestAdapter)) local canLearn = not not (canCraft and (duckAntenna or turtleChestAdapter or introspectionModule))
local userRecipes = Util.readTable(RECIPES_FILE) or { } local userRecipes = Util.readTable(RECIPES_FILE) or { }
local jobList local jobList
local resources local resources
@@ -1115,6 +1121,14 @@ local function getTurtleInventory()
return list return list
end end
if introspectionModule then
local list = { }
for i = 1,16 do
list[i] = introspectionModule.getInventory().getItemMeta(i)
end
return list
end
local inventory = { } local inventory = { }
for i = 1,16 do for i = 1,16 do
local qty = turtle.getItemCount(i) local qty = turtle.getItemCount(i)