Advertisement
Guest User

Sorter

a guest
Dec 12th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. x,y,z=1,1,0
  2. dir=0
  3. smeltables={
  4. "minecraft:iron_ore",
  5. "minecraft:gold_ore",
  6. "thermalfoundation:ore",
  7. "railcraft:ore_metal",
  8. "railcraft:ore_metal_poor"
  9. }
  10. furnaces=5
  11.  
  12. function Forward()
  13. while not turtle.forward() do end
  14. if (dir%2)==0 then y=y-1+(dir%4)
  15. else x=x+2-(dir%4)
  16. end
  17. end
  18.  
  19. function Up()
  20. while not turtle.up() do end
  21. z=z+1
  22. end
  23.  
  24. function Down()
  25. while not turtle.down() do end
  26. z=z-1
  27. end
  28.  
  29. function Right()
  30. turtle.turnRight()
  31. dir=(dir+1)%4
  32. end
  33.  
  34. function Left()
  35. turtle.turnLeft()
  36. dir=(dir-1)%4
  37. end
  38.  
  39. function CheckSmeltable(num)
  40. local data=turtle.getItemDetail(num)
  41. if data then
  42. for i=1,#smeltables do
  43. if data.name==smeltables[i] then return true end
  44. end
  45. end
  46. return false
  47. end
  48.  
  49. function MoveToFurnace()
  50. Right() Right() Forward() Left()
  51. local tries=0
  52. while not turtle.dropDown() and tries<furnaces-1 do
  53. Forward()
  54. tries=tries+1
  55. end
  56. Right() Right()
  57. for i=1,tries do Forward() end
  58. Right() Forward()
  59. end
  60.  
  61. function MoveToChest()
  62. Right() Forward()
  63. local data=turtle.getItemDetail()
  64. if data and data.name=="minecraft:cobblestone" then
  65. Left()
  66. turtle.drop()
  67. Left() Forward() Right()
  68. else
  69. local tries=0
  70. while not turtle.drop() do
  71. Up()
  72. tries=tries+1
  73. end
  74. for i=1,tries do Down() end
  75. Right() Right() Forward() Right()
  76. end
  77. end
  78.  
  79. while true do
  80. while turtle.suckDown() do end
  81. for i=1,16 do
  82. turtle.select(i)
  83. if turtle.getItemCount(i)>0 then
  84. if CheckSmeltable(i) then MoveToFurnace()
  85. else MoveToChest()
  86. end
  87. end
  88. end
  89. turtle.select(1)
  90. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement