Thought you might be interested to know I got a test program working. Turned out sleeping on it was the solution, had something working within 30 minutes of waking up.
If anyone is interested in taking a look and helping out, please see below.
I don't actually use the adapter with an inventory controller just yet, but it will hopefully be moved to connect to the ME Controller, the adapter with a database, and the ender chest. The idea being the inventory controller will update the database with items stored in the ME system, if possible. The inventory controller adapter will also probably keep track of items in the ender chest.
Test Program / Code:
Pastebin (easier to read, has correct Lua syntax highlighting): http://pastebin.com/tm9f2hQR
-- Title: me_exportbus test program
-- File Name: test
--Description: Reads all items in database and
-- attempts to export 1 instance of
-- each item to a chest through the
-- export bus
-- Notes: I use sides.bottom here, this will
-- be different depending on the placement
-- of your me_exportbus! I will eventually
-- write a function to set this value
-- dynamically (or maybe not, Im lazy)
-- Keep in mind the database itemstack info
-- is manually added at the moment, I will
-- eventually add a means of using an inventory
-- controller to manage the database programmatically
-- (if possible with ME system)
local component = require('component')
local sides = require('sides')
local db = component.database
local cont = component.me_controller --not actually used
local exBus = component.me_exportbus
local busSide = sides.bottom --you might need to change this
--for loop to print all the items in DB
--should dynamically calculate end of loop
for i = 1, 5 do
item = db.get(i)
print("--ITEM " .. i .. " START--")
for k,v in pairs(item) do
print("--ITEM " .. i .. " END--")
--for loop sets the export config to a different item
--each loop, prints the config, then tries to export 1 item.
--Should also dynamically calculated end of loop, but in actual
--real use I probably will have a function along the lines of
--exportItem(itemName) or something similar, which will do all
--the work required to set the export config and pump out a single
--instance of that item to the chest (resetting the config after)
for i = 0, 4 do
--start run i and set config for next item
print("--------- Run " .. i .. " Start ---------\n")
print("Set Config: ",exBus.setExportConfiguration(busSide, 1, db.address, i+1))
--print the config, comment this block out if you dont care
config = exBus.getExportConfiguration(busSide, 1)
print("\n!! Export Bus Config Start !!\n")
for k,v in pairs(config) do
print("\n!! Export Bus Config End !!\n")
print("Try Export: ",exBus.exportIntoSlot(busSide,i+1), "\n") -- try export an item
exBus.setExportConfiguration(0) --clear the config
This uses hard coded values at the moment, but eventually I'll change this to use an inventory controller to manager the database and export items.
Also, anyone know how to get Lua syntax highlighting in the code boxes?
- As soon as I set the configuration on an export bus it instantly starts trying to pump that item out of the ME system. Solution was to use a Redstone Card upgrade in the export bus. Then set the Redstone Mode to Active with signal (then never send it a signal, so that exBus.exportIntoSlot is the only time it will try move an item).
- I'm not sure if there is a way to get information about items in the ME system into the database. I did notice the latest version has added something to do exactly this though, so I may just have to wait until the mod pack my server uses get's an update.