Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Daraketh

Applied Energistics 2 using OC as an advanced import/export system

Question

UPDATE: I finally got a test program working. See post below if interested. Going to leave this here as I make changes/improve the functionality, any pointers or suggestions are still more then welcome!


 


Description:


  My friend and I are trying to get our OC computer to move items from an Applied Energistics 2 ME system into a chest (by any means)


 


Function:


  I would like functionality that allows me to transfer items from my ME system into a chest, either through the export bus, or directly through a controller (if possible), or even using a robot, literally any means is great.


 


Deadline:


  No deadline, would mostly just love some help. :)


 


Additional Information:


  We've made preliminary attempts with ExportIntoSlot and various other methods on both the ME controller and the ME export bus. We've been using the github appeng intergration code as a reference from HERE to try achieve this, but have only had problems thus far. The greatest success so far is getting an export bus to return false with exportBus.exportIntoSlot(i,1) returning as false.


 


I have previously managed to use a ComputerCraft turtle to do exactly this (I think using openPeripheral?), though this was with Applied Energistics 1.


 


Thank you in advance!


 


PS: If anyone is interested in having a crack, I can link some resources we've found that supposedly work, but none of the example code (or our various modifications to said example code) has worked thus far. I admit we're probably doing it wrong, any insight is great.


 


PPS: Decided to include them anyways, see below if you're interested.


 


https://github.com/MightyPirates/OpenComputers/tree/master-MC1.7.10/src/main/scala/li/cil/oc/integration/appeng


http://oc.cil.li/index.php?/topic/411-extracting-items-from-me-network-applied-energetics/


http://oc.cil.li/index.php?/topic/481-ae-item-management-puzzle-whats-the-best-way-to-do-this/


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hey all,

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.  :P

 

If anyone is interested in taking a look and helping out, please see below.

 

Basic Setup:

 

glxLntZ.png

 

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(k,v)
  end
  print("--ITEM " .. i .. " END--")
end

print("\n\n")

--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(k,v)
  end
  print("\n!! Export Bus Config End !!\n")

  print("Try Export: ",exBus.exportIntoSlot(busSide,i+1), "\n") -- try export an item

end

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?

 

Problems:

 

Solved:

            - 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).

 

Unsolved:

           - 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.

Link to post
Share on other sites
  • 0

For anyone who is interested, the below code solves the previously unsolved problem. Current versions of OpenComputers add the .store method on ME controllers, allowing the storing of item information in a database for use with the export bus. In-world configuration has an adapter touching an export bus and an ME controller, and has a database upgrade in the adapter.

 

This code solves the problem of exporting one of each item, which I found of particular interest due to Thaumcraft's fancy new scan-everything-in-a-chest feature...

 

https://pastebin.com/wQJNJkej

 

--Required API's
local component = require "component"
local serialization = require "serialization"
local sides = require "sides"
 
--adapter is connected to an ME controller, and export bus.
local me = component.me_controller
--export bus is has a redstone card set so it doesn't auto-export
local bus = component.me_exportbus
 
--adapter has an database upgrade
local db = component.database
 
--Loop over items in the me network
for key,item in ipairs(me.getItemsInNetwork()) do
 
  --print out each item for debugging; serializing to see the entire data table
  print(item.name.." :: "..serialization.serialize(me.getItemsInNetwork(item)))
 
  --Use the item as a filter to find an item in the me network, and store its
  --itemstack data into the database
  me.store(item,db.address,1,1)
 
  --configure the export bus to export that item
  bus.setExportConfiguration(sides.left,1,db.address,1)
 
  --trigger an export
  bus.exportIntoSlot(sides.left,1)
 
  --clear out the database entry. Might not be needed...
  db.clear(1)
end

 

 

Hopefully this is helpful.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.