Xyzzy

ess

Mar 29th, 2015
238
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rednet.open("right")
  2. local c = peripheral.wrap("bottom")
  3. local a = peripheral.wrap("front")
  4. local f = peripheral.wrap("top")
  5. local redstoneDir = "back"
  6. --Added this incase you are pastebinning the code
  7. local crystals = {}
  8.  
  9. function scanSlot(slot)
  10.     c.pushItemIntoSlot("up", slot,1,1)
  11.     turtle.drop()
  12.     data = table.concat(a.getAspects())
  13.     crystals[data] = slot
  14.     turtle.suck()
  15.     c.pullItemIntoSlot("up", 1, 1,slot)
  16. end  
  17.  
  18. function scanSlots()
  19.    redstone.setOutput(redstoneDir, true)
  20.    for i = 1, 56 do
  21.       if c.getStackInSlot(i) then
  22.          scanSlot(i)
  23.       end
  24.    end
  25.    redstone.setOutput(redstoneDir, false)
  26. end
  27.  
  28. function essentia(aspect, numAspect)
  29.    if not f.getStackInSlot(1) then
  30.       c.pushItemIntoSlot("up", crystals[aspect], numAspect,1)
  31.       f.pullItemIntoSlot("down", 1, numAspect,1)  
  32.    end
  33.    while f.getStackInSlot(1) do
  34.       print("Waiting for chest to empty...")
  35.       sleep(3)
  36.    end
  37.    print("done")
  38. --   sleep(15)
  39. end
  40.  
  41. function awaitRednet()
  42.   local id, msg = rednet.receive()
  43. --  term.write(msg)
  44.   local essData = {}
  45.   essData = textutils.unserialize(msg)
  46.   print(essData[1]..":"..essData[2])
  47.   essentia(essData[1], essData[2])
  48.   rednet.send(id, "Complete")
  49. end
  50.  
  51. print("Scanning crystals...")
  52. scanSlots()
  53. print("Done scanning crystals!")
  54.  
  55. while true do
  56.    awaitRednet()
  57. end
RAW Paste Data