Advertisement
Guest User

Furnace

a guest
Dec 12th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. x,y,z=1,1,0
  2. dir=0
  3. furnaces=5
  4.  
  5. function Forward()
  6. while not turtle.forward() do end
  7. if (dir%2)==0 then y=y-1+(dir%4)
  8. else x=x+2-(dir%4)
  9. end
  10. end
  11.  
  12. function Up()
  13. while not turtle.up() do end
  14. z=z+1
  15. end
  16.  
  17. function Down()
  18. while not turtle.down() do end
  19. z=z-1
  20. end
  21.  
  22. function Right()
  23. turtle.turnRight()
  24. dir=(dir+1)%4
  25. end
  26.  
  27. function Left()
  28. turtle.turnLeft()
  29. dir=(dir-1)%4
  30. end
  31.  
  32. function EmptyInventory()
  33. Right() Forward() Forward() Forward() Forward()
  34. Left() Forward() Up() Up() Right()
  35. for i=1,16 do
  36. turtle.select(i)
  37. if turtle.getItemCount(i)>0 do
  38. local tries=0
  39. while not turtle.drop() do
  40. Up()
  41. tries=tries+1
  42. end
  43. for n=1,tries do Down() end
  44. end
  45. end
  46. turtle.select(1)
  47. Right() Down() Down() Forward() Right()
  48. Forward() Forward() Forward() Forward() Right()
  49. end
  50.  
  51. function InventoryCount()
  52. local sum=0
  53. for i=1,16 do
  54. sum=sum+turtle.getItemCount(i)
  55. end
  56. return sum
  57. end
  58.  
  59. while true do
  60. Right()
  61. turtle.suckUp()
  62. for i=1,furnaces-1 do
  63. Forward()
  64. turtle.suckUp()
  65. end
  66. Right() Right()
  67. while x>1 do Forward() end
  68. Right()
  69. if InventoryCount()>0 then EmptyInventory() end
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement