Damaged

AE Bee scanning

Apr 1st, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.12 KB | None | 0 0
  1. local aeStorage = peripheral.wrap("appeng_me_tilecraftingterminal_0")
  2. local analyzerDirection = "west"
  3. local trashDirection = "east"
  4. local memoryDirection = "down"
  5. local aeDirection = "up"
  6.  
  7. local memoryChest = peripheral.wrap("back")
  8.  
  9. function printDebug(textString)
  10.    print(textString)
  11. end
  12.  
  13. while true do
  14.    local allItems = aeStorage.getAvailableItems()
  15.    printDebug("Gotten ae data")
  16.    for key, value in pairs (allItems) do
  17.       printDebug("Working on item #"..tostring(key))
  18.       if value.id == 13340 then
  19.          printDebug("Found a drone: "..value.name)
  20.          local thisBee = {
  21.             id = value.id;
  22.             name = value.name;
  23.             qty = value.qty;
  24.          }
  25.          printDebug("Grabbing: "..textutils.serialize(thisBee))
  26.          while aeStorage.extractItem( thisBee , memoryDirection ) ~= 0 do
  27.             for i = 1, memoryChest.getInventorySize() do
  28.                printDebug("Grabbed a stack from the network: "..textutils.serialize(memoryChest.getStackInSlot(i)))
  29.                if memoryChest.getStackInSlot( memoryChest.getInventorySize() ) then
  30.                   printDebug("Inventory full, dumping to trash")
  31.                   while memoryChest.pushItem(trashDirection, i, 64, 1) == 0 do sleep(1) end
  32.                else
  33.                   local beeData = memoryChest.getStackInSlot(i)
  34.                   if not beeData.beeInfo.isAnalyzed then
  35.                      printDebug("Bee isn't analyzed, sending")
  36.                      memoryChest.pushItem(analyzerDirection, i, 64, 1)
  37.                      printDebug("Waiting for analyzer")
  38.                      while memoryChest.pullItem(analyzerDirection, 9, 64, i) == 0 do sleep (1) end
  39.                      printDebug("Got bee back")
  40.                   end
  41.                end
  42.                break
  43.             end
  44.          end
  45.          break
  46.       end
  47.    end
  48.    break
  49. end
  50.    --[[
  51.    while aeStorage.extractItem( { id = 13340; isAnalyzed = false; qty = 64; }, analyzerDirection ) do
  52.       while aeStorage.insertItem( 9, 64, analyzerDirection) == 0 do sleep(1) end
  53.       break
  54.    end
  55.    break
  56.    ]]--
  57.      
  58.    --sleep(1200)
Advertisement
Add Comment
Please, Sign In to add comment