Advertisement
Ganeesya

phial

May 11th, 2015
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. if not turtle then
  2. write("this program need narrsic turtle")
  3. shell.exit()
  4. end
  5.  
  6. function isEmptyPhial( target )
  7. if target and target.display_name and target.display_name == "Glass Phial" then
  8. return true
  9. end
  10. if target and target.damage and target.name
  11. and target.damage == 0
  12. and target.name == "Thaumcraft:ItemEssence" then
  13. return true
  14. end
  15. return false
  16. end
  17.  
  18. function pickRefuel( fuel )
  19. for i = 1, 16 do
  20. local ans = turtle.getItemDetail(i)
  21. if ans and fuel and fuel.id and ans.name == fuel.id then
  22. turtle.select(i)
  23. turtle.refuel()
  24. turtle.select(1)
  25. break
  26. end
  27. end
  28. end
  29.  
  30. function init()
  31. while not turtle.detectDown() do
  32. turtle.down()
  33. end
  34.  
  35. if peripheral.wrap("bottom") and peripheral.wrap("bottom").getAllStacks then
  36. local chest = peripheral.wrap("bottom")
  37. for i = 1, 16 do
  38. if turtle.getItemCount(i) > 0 then
  39. chest.pullItem("up",i)
  40. end
  41. end
  42. local phailMany = 0
  43. for k, v in pairs(chest.getAllStacks()) do
  44. if turtle.getFuelLevel() < 20 and v.all().burn_time then
  45. chest.pushItem("up",k)
  46. pickRefuel( v.all() )
  47. end
  48.  
  49. if isEmptyPhial(v.all()) and phailMany < 64 then
  50. local chestin = v.all().qty
  51. chest.pushItem("up",k,64 - phailMany)
  52. phailMany = phailMany + chestin
  53. end
  54. end
  55. else
  56. write("need under chest")
  57. shell.exit()
  58. end
  59. end
  60.  
  61. function phialTarget()
  62. for i = 1, 16 do
  63. if isEmptyPhial( turtle.getItemDetail(i) ) then
  64. turtle.select(i)
  65. turtle.place()
  66. turtle.select(1)
  67. break
  68. end
  69. end
  70. end
  71.  
  72. function isSideThaum(side)
  73. if peripheral.wrap(side) and peripheral.wrap(side).getAspects then
  74. return true
  75. end
  76. return false
  77. end
  78.  
  79. function Phialing()
  80. if isSideThaum("front") then
  81. local asps = peripheral.wrap("front").getAspects()
  82. if asps[1] and peripheral.wrap("front").getAspectCount( asps[1] ) >= 8 then
  83. while peripheral.wrap("front").getAspectCount( asps[1] ) >= 8 do
  84. phialTarget()
  85. sleep(0.5)
  86. end
  87. end
  88. end
  89. end
  90.  
  91. function isAspectFillLevel(side,lvl)
  92. if isSideThaum(side) then
  93. local asps = peripheral.wrap(side).getAspects()
  94. if asps[1] and peripheral.wrap(side).getAspectCount( asps[1] ) >= lvl then
  95. return true
  96. end
  97. end
  98. return false
  99. end
  100.  
  101. function WatchWaiting()
  102. while not isAspectFillLevel("front",8) do
  103. sleep(1)
  104. end
  105. end
  106.  
  107. while true do
  108. init()
  109. WatchWaiting()
  110. Phialing()
  111. for i = 1, 4 do
  112. if not turtle.up() then
  113. break
  114. end
  115. Phialing()
  116. end
  117. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement