Advertisement
EphemeralKap

Untitled

Dec 4th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. local trees = 23
  2. local currentPos = 0
  3. local lastStatus = 0
  4. local status = 0 -- 0Clueless-1Starting-2Harvesting-3Returning-4onRail-5OffRailDirt-6RailEnd
  5.  
  6.  
  7. -- refuel the turtle with slot 1, coal
  8. function Refuel()
  9. turtle.select(1)
  10. turtle.refuel(3)
  11. end
  12.  
  13. --grabs fuel from coal chest
  14. function GrabFuel()
  15. turtle.turnLeft()
  16. turtle.select(1)
  17. turtle.suck()
  18. turtle.turnRight()
  19. end
  20.  
  21. -- move forward once and suck up items front, left and right
  22. function Forward()
  23. turtle.forward()
  24. turtle.suckDown()
  25. turtle.turnLeft()
  26. turtle.suck()
  27. turtle.turnRight()
  28. turtle.turnRight()
  29. turtle.suck()
  30. end
  31.  
  32. -- This function checks where the turtle is located on the rail, it's needed in case the program boots while the
  33. -- turtle is not at the start of the dropoff location
  34. function UpdateStatus()
  35. local s, under = turtle.inspectDown()
  36. local s2, front = turtle.inspect()
  37.  
  38.  
  39. lastStatus = status
  40. if s then
  41. if under.name == "minecraft:cobblestone" then
  42. status = 1
  43. end
  44. if under.name == "minecraft:torch" then
  45. status = 4
  46. end
  47. if under.name == "minecraft:dirt" then
  48. status = 5
  49. end
  50. end --todo: check if on right y level, should be if s is false
  51.  
  52. if s2 then
  53. if front.name == "minecraft:chest" then
  54. turtle.turnLeft()
  55. turtle.turnLeft()
  56. status = 1
  57. end
  58. if front.name == "minecraft:log" then
  59. turtle.turnLeft()
  60. UpdateStatus()
  61. end
  62. if front.name == "minecraft:gravel" then
  63. status = 6
  64. end
  65. elseif status == 4 then
  66. turtle.forward()
  67. end
  68.  
  69. print("Updated Status: " .. lastStatus .. " to " .. status)
  70.  
  71. end
  72.  
  73. -- main loop
  74. -- reset -> refuel -> pickup fuel -> chop -> deposit
  75. while true do
  76. if status == 0 then
  77. print("Updating status..")
  78. UpdateStatus()
  79.  
  80. end
  81. if turtle.getItemCount(1) < 16 and status == 0 then
  82. print("Grabbing Fuel..")
  83. GrabFuel()
  84. end
  85. if turtle.getFuelLevel() < 10 then
  86. print("Refueling..")
  87. Refuel()
  88. end
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement