This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
sankao's profile picture

Applied Energistics + OpenP

Started by sankao, 31 March 2014 - 09:29 AM
sankao #1
Posted 31 March 2014 - 11:29 AM
Hey, I was looking to do something I think similar, and this post was the first answer on google for applied energistics + open peripheral, so I'm posting my solution to get items from an applied energistics terminal programmatically.
I'm a complete beginner at computercraft and lua but hopefully that will point other beginners in the right direction.

tArgs = {...}
if #tArgs == 0 then
    print("usage get <itemID> (count=64) (Metatag)")
    exit()
end
itemID = tonumber(tArgs[1])
qty = 64
if #tArgs > 1 then
    qty = tonumber(tArgs[2])
end
dmg = -1
if #tArgs > 2 then
    dmg = tonumber(tArgs[3])
end   
ae = peripheral.wrap("right")
cust = {}
cust["id"] = itemID
cust["qty"] = qty
if dmg >= 0 then
    cust["dmg"] = dmg
end																																																																	 
print(textutils.serialize(cust))																																																											  
ret = ae.extractItem(cust, "east")

This trivial example is executed in a turtle sitting next to an ae terminal.
Cranium #2
Posted 31 March 2014 - 02:26 PM
I split your topic into its own, so it can get more exposure.
blipman17 #3
Posted 01 April 2014 - 09:42 AM
I tried that before, and you can only monitor with applied energistics. you can't craft or request using any computer as far as I know.
But I don't know if an update has done some magic.
Try using a logistics request pipe next to a turtle.
They can request as far as i know.
DerKoch #4
Posted 03 April 2014 - 09:41 AM
Went into ragemode because I could not extract a test-item for an hour, turns out the item being enchanted was the error…Now, how do I get those enchanted items out of my system without extracting the ones that are not enchanted (guess it's more AE related)?
Also worth mentioning: items that can not be stacked in the inventory are extracted as qty=1, no matter what amount was given.
Edited on 03 April 2014 - 07:42 AM
sankao #5
Posted 09 April 2014 - 01:15 PM
Went into ragemode because I could not extract a test-item for an hour, turns out the item being enchanted was the error…Now, how do I get those enchanted items out of my system without extracting the ones that are not enchanted (guess it's more AE related)?
Also worth mentioning: items that can not be stacked in the inventory are extracted as qty=1, no matter what amount was given.

Hi, sorry for the delayed answer, I didn't notice that my original reply got split off in a different thread.
I assume you posted this ticket on github:
https://github.com/OpenMods/OpenPeripheral/issues/145
I confirm on my side as well, extracting enchanted items simply doesn't work.
For the quantity issue, a simple loop depending on the item's maxSize property would do the trick.
blipman17 #6
Posted 10 April 2014 - 10:02 AM
DerKoch,

If you are finished, can I take a look at your code? I'm trying to do thesame for like a long time but always gave up on it.
DerKoch #7
Posted 13 April 2014 - 09:58 PM
I indeed posted the ticket and also used a loop as a workaround to spit out the items.^^

@blipman17:
What code? The code to use extractItem()? Everything is in the first post and it works really well. Just put the Turtle at some side of the AE Terminal, wrap the Terminal and extract the items into the Turtle. The wrapping side depends on the Turtle's orientation and the extraction side depends on which side you put the Turtle. E.g. if the side the turtle communicates with the Terminal is looking in the south, the direction you add in the extractItem()-function is "south". The table you specify has "id", "qty" and, if you want to exract damaged items, "dmg". All these values can be obtained via getAvailableItems() (a table which containes all items that are in the AE system) or simply by looking into the terminal.with NEI installed (shows ids and metavalues when hovering over items).
blipman17 #8
Posted 16 April 2014 - 11:16 PM
thank you, sorry for replying on such an old post
Shrooblord #9
Posted 17 April 2014 - 06:18 PM
This is quite a nifty way of accessing AE systems - thanks for this!

Is the 'orientation' thing an AE term? I don't recall computers or turtles ever dealing in "north", "south", etc. - only in "front", "back" etc..
CometWolf #10
Posted 17 April 2014 - 06:30 PM
openP, the mod which makes AE interaction possible, uses north, south, east, and i believe it's up and down for it's orientation. I believe it's done that way since that's how vanilla mc handles it. It's caused me some headache in the past…
Shrooblord #11
Posted 17 April 2014 - 06:54 PM
I've never really used openPeripherals before, but always had it installed. I was just looking into messing with CC+AE - thanks for the heads-up.