Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- =============VARIABLES===================
- note = peripheral.wrap("left")
- -- =============VARIABLES END===============
- -- ============FUNCTIONS====================
- function NewLine(Str,Int)
- local barLength = 40
- local tempPercentage = 0
- term.clear()
- term.setCursorPos(1,2)
- print("-------------[SeedBot v0.6]------------")
- term.setCursorPos(11,5)
- write("v {Current action} v")
- term.setCursorPos(Int,8)
- print(Str)
- term.setCursorPos(12,12)
- write("[Current Fuel %"..(math.floor(turtle.getFuelLevel())))
- write("]")
- term.setCursorPos(1,13)
- barLength = turtle.getFuelLevel() / 100 * 40
- if barLength > 40 then barLength = 40 end
- if term.isColor() then
- term.setBackgroundColor(colors.green)
- else
- term.setBackgroundColor(colors.white)
- end
- for i =1,(barLength) do
- write(" ")
- end
- if barLength < 40 then
- if term.isColor() then term.setBackgroundColor(colors.red) else term.setBackgroundColor(colors.gray) end
- local remainingBarLength = (40 - barLength)
- for i =1,(remainingBarLength) do
- write(" ")
- end
- end
- term.setBackgroundColor(colors.black)
- end
- function CheckFuel(bool)
- local fuel = turtle.getFuelLevel()
- --Checking fuel level & fueling if low
- if turtle.getFuelLevel() < 25 then
- GetFuel()
- return true
- else
- return false
- end
- end
- function GetFuel()
- if not done then NewLine("Getting fuel",15) end
- --print("Current Fuel Level: "..turtle.getFuelLevel())
- turtle.select(16)
- while turtle.getFuelLevel() <= 100 do
- if not turtle.suckUp(1) and (turtle.getFuelLevel() <= 100) then
- NewLine("No fuel in fuel chest!",10)
- turtle.select(1)
- done = true
- break
- end
- turtle.refuel(1)
- turtle.drop(turtle.getItemCount(16))
- NewLine("Getting fuel",15)
- --print("Current Fuel Level: "..turtle.getFuelLevel())
- end
- turtle.select(1)
- end
- function CheckPosition()
- if turtle.up() then
- NewLine("Returning to start position",8)
- turtle.down()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.back()
- os.reboot()
- end
- end
- function GetSeed()
- turtle.suck()
- print("Getting seeds")
- end
- function AnalyzeSeed()
- turtle.dropDown()
- os.sleep(6)
- turtle.suckDown()
- print("Analyzing seeds")
- end
- function DepositSeed()
- turtle.turnRight()
- print("Storing seeds")
- os.sleep(1)
- for i=1,4 do
- turtle.drop()
- turtle.select(i)
- end
- os.sleep(1)
- turtle.select(1)
- turtle.turnLeft()
- end
- -- ============FUNCTIONS END====================
- -- ===========STARTUP SEQUENCE==========
- if turtle.getFuelLevel() > 4 then CheckPosition() end
- CheckFuel()
- -- ===========STARTUP SEQUENCE END======
- -- ===========MAIN LOOP=================
- while not done do
- GetSeed()
- if turtle.compareTo(2) then
- NewLine("No seeds left in the chest!",10)
- for i=0,4 do
- note.playNote(6, i)
- os.sleep(.2)
- end
- break
- end
- AnalyzeSeed()
- DepositSeed()
- CheckFuel()
- end
- -- ===========MAIN LOOP END=================
Advertisement
Add Comment
Please, Sign In to add comment