Advertisement
readix

turtle aspect ephys

Jul 17th, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. local aspectController = 113
  2. local emptyer = 109
  3.  
  4. local ECD = peripheral.wrap("left")
  5. local ECB = peripheral.wrap("bottom")
  6.  
  7. rednet.open("right")
  8.  
  9. local analyzer = peripheral.wrap("front")
  10. local furnace = peripheral.wrap("top")
  11.  
  12. local mapSlot = {}
  13. local mapChest = {}
  14.  
  15. function map(chest, direction, chestName)
  16. for i = 1, 27 do
  17. -- term.clear()
  18. term.setCursorPos(1,1)
  19. print("scanning "..i.."/27 ["..chestName.."]")
  20. local amnt = chest.pushItem(direction, i, 1, 1)
  21.  
  22. if amnt ~= 0 then
  23. turtle.drop()
  24. local auram, aspect = analyzer.getAspects()
  25. turtle.suck()
  26. chest.pullItem(direction, 1, 1, i)
  27. rednet.send(emptyer, "emptyplz")
  28.  
  29. if aspect == nil then
  30. aspect = auram
  31. elseif aspect == "auram" then
  32. aspect = auram
  33. end
  34. print("found "..aspect.." ")
  35. mapSlot[aspect] = i
  36. mapChest[aspect] = chestName
  37. end
  38. end
  39. end
  40.  
  41. local start = os.time()
  42. map(ECD, "east", "left")
  43. map(ECB, "up", "bottom")
  44. print("turtle ready ! ("..(os.time() - start).."m)")
  45.  
  46. while true do
  47. sender, message = rednet.receive()
  48.  
  49. if sender == aspectController then
  50. local aspect = textutils.unserialize(message)
  51.  
  52. local aspectName = string.lower(aspect["name"])
  53. local aspectCount = math.ceil(aspect["quantity"] / 2)
  54.  
  55. local chest = mapChest[aspectName]
  56.  
  57. print(aspectCount.." "..aspectName.." ("..chest..")")
  58. if chest == "bottom" then
  59. ECB.pushItem("up", mapSlot[aspectName], aspectCount, 1)
  60. elseif chest == "left" then
  61. ECD.pushItem("east", mapSlot[aspectName], aspectCount, 1)
  62. end
  63.  
  64. turtle.turnRight()
  65. turtle.drop()
  66. turtle.turnLeft()
  67.  
  68. sleep(1) -- let the time for the item to get in furnace
  69. while furnace.getStackInSlot(1) ~= nil do
  70. sleep(5)
  71. end
  72. end
  73.  
  74. rednet.send(aspectController, "done")
  75. end
  76.  
  77. rednet.close("right")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement