DubSlime

Hemp / Sugarcane FubFarm

Sep 1st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. -- VARIABLES --
  2. timer = 300
  3.  
  4.  
  5. function clearScreen()
  6. term.setBackgroundColor(colours.white)
  7. term.clear()
  8. term.setBackgroundColor(colours.lime)
  9. term.setCursorPos(1,1)
  10. term.clearLine()
  11. term.setBackgroundColor(colours.lightGrey)
  12. term.setCursorPos(1,3)
  13. term.clearLine()
  14. term.setCursorPos(2,3)
  15. print("Carburant")
  16. term.setCursorPos(1,6)
  17. term.clearLine()
  18. term.setCursorPos(2,6)
  19. print("Recolte")
  20. end
  21.  
  22. function screen(mes, xpos, ypos)
  23. term.setBackgroundColor(colours.lime)
  24. term.setCursorPos(1,1)
  25. print(" === Hemp / Sugarcane DubFarmer ===")
  26. term.setCursorPos(xpos,ypos)
  27. term.setTextColor(colours.black)
  28. term.setBackgroundColor(colours.white)
  29. term.clearLine()
  30. term.setCursorPos(xpos, ypos)
  31. print(">: "..mes)
  32. end
  33.  
  34. function recharger()
  35. screen("Recherche de carburant en cours...", 3, 4)
  36. fuelInitial = turtle.getFuelLevel()
  37. for i = 1, 16 do
  38. turtle.select(i)
  39. if turtle.refuel(0) then
  40. screen("Fuel trouve slot "..i, 3, 4)
  41. turtle.refuel()
  42. drawFuelLevel()
  43. end
  44. end
  45. drawFuelLevel()
  46. if fuelInitial == turtle.getFuelLevel() and turtle.getFuelLevel() == 0 then
  47. screen("Aucun carburant. Recharger", 3, 4)
  48. end
  49. end
  50.  
  51. function drawFuelLevel()
  52. screen("Fuel Level : "..turtle.getFuelLevel().." / "..turtle.getFuelLimit(),3,4)
  53. term.setBackgroundColor(colours.red)
  54. term.setCursorPos(1,5)
  55. term.clearLine()
  56. perc = math.floor((39 / turtle.getFuelLimit())*turtle.getFuelLevel())
  57. term.setBackgroundColor(colours.orange)
  58. for i=1, perc do
  59. term.setCursorPos(i,5)
  60. term.write(" ")
  61. end
  62. end
  63.  
  64. function check()
  65. result,id = turtle.inspect()
  66. if result then
  67. if id.name == "eng_toolbox:hemp" then
  68. turtle.dig()
  69. end
  70. end
  71. result,id = turtle.inspectDown()
  72. if result then
  73. if id.name == "eng_toolbox:hemp" then
  74. turtle.digDown()
  75. end
  76. end
  77. end
  78.  
  79. function emptyInv()
  80. turtle.select(1)
  81. for i=1, 15 do
  82. turtle.select(i)
  83. while turtle.getItemCount()>0 do
  84. turtle.dropDown()
  85. end
  86. end
  87. end
  88.  
  89. function countdown()
  90. delai = timer
  91. while delai >0 do
  92. minutes = math.floor(delai/60)
  93. secondes = delai%60
  94. screen("Delai avant recolte : "..minutes..":"..secondes,3,7)
  95. term.setBackgroundColor(colours.red)
  96. term.setCursorPos(1,8)
  97. term.clearLine()
  98. percD = math.floor((39 / timer) * delai)
  99. term.setCursorPos(1,8)
  100. for i=1, percD do
  101. term.setBackgroundColor(colours.orange)
  102. term.setCursorPos(i,8)
  103. term.write(" ")
  104. end
  105. sleep(1)
  106. delai = delai - 1
  107. end
  108. end
  109.  
  110. function recolte()
  111. turtle.select(1)
  112. screen("Recolte en cours...", 3, 7)
  113. term.setBackgroundColor(colours.lime)
  114. term.setCursorPos(1,8)
  115. term.clearLine()
  116. turtle.up()
  117. for i=1, 4 do
  118. result,id = turtle.inspect()
  119. while id.name ~= "minecraft:glass" do
  120. check()
  121. result,id = turtle.inspect()
  122. if id.name ~= "minecraft:glass" then
  123. turtle.forward()
  124. end
  125. drawFuelLevel()
  126. end
  127. turtle.turnRight()
  128. end
  129. turtle.down()
  130. emptyInv()
  131. turtle.select(16)
  132. turtle.suck()
  133. countdown()
  134. end
  135.  
  136. clearScreen()
  137. screen("", 3, 4)
  138. while true do
  139. recharger()
  140. recolte()
  141. end
Add Comment
Please, Sign In to add comment