Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- VARIABLES --
- timer = 300
- function clearScreen()
- term.setBackgroundColor(colours.white)
- term.clear()
- term.setBackgroundColor(colours.lime)
- term.setCursorPos(1,1)
- term.clearLine()
- term.setBackgroundColor(colours.lightGrey)
- term.setCursorPos(1,3)
- term.clearLine()
- term.setCursorPos(2,3)
- print("Carburant")
- term.setCursorPos(1,6)
- term.clearLine()
- term.setCursorPos(2,6)
- print("Recolte")
- end
- function screen(mes, xpos, ypos)
- term.setBackgroundColor(colours.lime)
- term.setCursorPos(1,1)
- print(" === Hemp / Sugarcane DubFarmer ===")
- term.setCursorPos(xpos,ypos)
- term.setTextColor(colours.black)
- term.setBackgroundColor(colours.white)
- term.clearLine()
- term.setCursorPos(xpos, ypos)
- print(">: "..mes)
- end
- function recharger()
- screen("Recherche de carburant en cours...", 3, 4)
- fuelInitial = turtle.getFuelLevel()
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then
- screen("Fuel trouve slot "..i, 3, 4)
- turtle.refuel()
- drawFuelLevel()
- end
- end
- drawFuelLevel()
- if fuelInitial == turtle.getFuelLevel() and turtle.getFuelLevel() == 0 then
- screen("Aucun carburant. Recharger", 3, 4)
- end
- end
- function drawFuelLevel()
- screen("Fuel Level : "..turtle.getFuelLevel().." / "..turtle.getFuelLimit(),3,4)
- term.setBackgroundColor(colours.red)
- term.setCursorPos(1,5)
- term.clearLine()
- perc = math.floor((39 / turtle.getFuelLimit())*turtle.getFuelLevel())
- term.setBackgroundColor(colours.orange)
- for i=1, perc do
- term.setCursorPos(i,5)
- term.write(" ")
- end
- end
- function check()
- result,id = turtle.inspect()
- if result then
- if id.name == "eng_toolbox:hemp" then
- turtle.dig()
- end
- end
- result,id = turtle.inspectDown()
- if result then
- if id.name == "eng_toolbox:hemp" then
- turtle.digDown()
- end
- end
- end
- function emptyInv()
- turtle.select(1)
- for i=1, 15 do
- turtle.select(i)
- while turtle.getItemCount()>0 do
- turtle.dropDown()
- end
- end
- end
- function countdown()
- delai = timer
- while delai >0 do
- minutes = math.floor(delai/60)
- secondes = delai%60
- screen("Delai avant recolte : "..minutes..":"..secondes,3,7)
- term.setBackgroundColor(colours.red)
- term.setCursorPos(1,8)
- term.clearLine()
- percD = math.floor((39 / timer) * delai)
- term.setCursorPos(1,8)
- for i=1, percD do
- term.setBackgroundColor(colours.orange)
- term.setCursorPos(i,8)
- term.write(" ")
- end
- sleep(1)
- delai = delai - 1
- end
- end
- function recolte()
- turtle.select(1)
- screen("Recolte en cours...", 3, 7)
- term.setBackgroundColor(colours.lime)
- term.setCursorPos(1,8)
- term.clearLine()
- turtle.up()
- for i=1, 4 do
- result,id = turtle.inspect()
- while id.name ~= "minecraft:glass" do
- check()
- result,id = turtle.inspect()
- if id.name ~= "minecraft:glass" then
- turtle.forward()
- end
- drawFuelLevel()
- end
- turtle.turnRight()
- end
- turtle.down()
- emptyInv()
- turtle.select(16)
- turtle.suck()
- countdown()
- end
- clearScreen()
- screen("", 3, 4)
- while true do
- recharger()
- recolte()
- end
Add Comment
Please, Sign In to add comment