Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This file uses the functions from Methods
- require("Methods")
- resetPos()
- -- Calculating Fuel Level and Fuel Needed ( Also caching file into a list )
- local file = fs.open("Settings", "r")
- local list = {}
- local line = file.readLine()
- while line do
- list[#list+1] = line
- line = file.readLine()
- end
- file.close()
- local length = list[4]
- local width = list[5]
- local fuelLevel = turtle.getFuelLevel()
- local fuelNeeded = (length * width) + (length + width)
- if(fuelLevel > fuelNeeded) then
- local direction = list[6]
- local nextTurn
- local lastTurn
- if (direction == "LEFT") then
- nextTurn = turtle.turnLeft
- lastTurn = turtle.turnRight
- else
- nextTurn = turtle.turnRight
- lastTurn = turtle.turnLeft
- end
- turtle.forward()
- while(length > 0) do
- nextTurn()
- getCrop()
- while (width > 0) do
- turtle.forward()
- getCrop()
- width = width - 1
- end
- lastTurn()
- length = length - 1
- width = list[5]
- turtle.forward()
- tempTurn = nextTurn
- nextTurn = lastTurn
- lastTurn = tempTurn
- end
- resetPos()
- -- Starts a timer that lasts 500 seconds. After the timer ends, the turtle reboots, and therefore repeats the program (Assuming the program is named 'startup' and has fuel)
- local timerID = os.startTimer(500)
- local event, id
- repeat
- event, id = os.pullEvent("timer")
- until id == timerID
- os.reboot()
- end
- -- If the turtle doesn't have fuel, it will display this message telling the user to feed it or fuck off
- print("NOT ENOUGH FUEL BRO")
Add Comment
Please, Sign In to add comment