5 posts
Posted 22 March 2014 - 07:11 PM
I'm running the (ftb) Direwolf20(1.64) pack and I'm trying to figure out how to retrieve a list of all items in the AE network. Preferably like the now defunct MiscPeripheral's ME-bridge with its getList().
The end result is going to be used to display on a monitor down the line ^^*
But at the moment I'd be happy with just the lines needed to get the amount of cobble and dirt stored in the network so I can start poking around…
Edited on 22 March 2014 - 06:12 PM
1281 posts
Posted 22 March 2014 - 07:25 PM
Connect your computer to the ME drive and use the included openP program called docs on it.
Type this into the shell
openp/docs side
It will tell you all the functions the peripheral supports, and can also give you more in-depth information about a specific function. Chances are it's something like getStacks.
5 posts
Posted 23 March 2014 - 09:34 AM
Well,,, I ditched trying to interact with ME directly ^^* Couldn't make heads or tails of it… Workaround: Logistics Request Pipe…
Following code assumes a 6 wide and 4 high screen at top of computer and a LP request pipe below the computer. Thing that takes the longest is checking the amount of items. Known issues: If run at startup you need to sleep for a few seconds because either LP, AE or the interaction takes a while to be ready. If the program is run very near to server-start, the getAvailableItems returns 0 items. This also means that if the LP/AE network doesn't contain any items it will throw a hissy-fit…
function sortByAmount(x, y)
return x.amount > y.amount
end
function checkAmount(itemList)
for key,value in pairs (itemList) do
itemList[key].amount = lp.getItemAmount(itemList[key].id)
if (key%100 == 0) then
sleep(0.00000000000000000000000000000001)
end
end
end
function updateDisplay()
monX = 1
monY = 1
mon.clear()
for i = 1, 208,1 do
name = itemList[i].name
amount = itemList[i].amount
mon.setCursorPos(monY, monX)
mon.write(name)
mon.setCursorPos(monY+28-6,monX)
mon.write(": ")
amountString = tostring(amount)
mon.setCursorPos(monY+28-string.len(amountString),monX)
mon.write(amountString)
monX = monX+1
if monX == 53 then
monX = 1
monY = monY+31
end
end
end
lp = peripheral.wrap("bottom")
mon = peripheral.wrap("top")
mon.setTextScale(0.5)
mon.clear()
itemList={}
n=1
myList = lp.getAvailableItems()
print(#myList)
print("import started")
for key,value in pairs( myList ) do
z = myList[key]
id = z[1]
itemList[n] = {}
itemList[n].id = id
itemList[n].name = lp.getUnlocalizedName(itemList[key].id)
n= n+1
end
while true do
print("getAmount")
checkAmount(itemList)
print("import done")
table.sort(itemList, sortByAmount)
print("updateDisplay")
updateDisplay()
sleep(2)
end
Edited on 23 March 2014 - 08:10 PM