Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---@diagnostic disable: lowercase-global
- -- Getting fuel level
- local fuelLevel = turtle.getFuelLevel()
- -- Change it to false if you want turtle to go left instead of right
- local direction = true
- local directionNew = direction
- -- Calculating the amount of fuel needed and storing it in fuelNeeded
- local fuelNeeded = (13*13) + 27
- -- Making function to get the slot index of the seed
- local function getSeedIndex()
- for slot = 1, 16, 1 do
- local item = turtle.getItemDetail(slot)
- if ( (item ~= nil) and ( (string.match(item.name, "seed") ) or (string.match(item.name, "potato") ) or (string.match(item.name, "carrot") ) ) ) then
- return slot
- break
- end
- end
- end
- -- Making function to take crops
- local function getCrop()
- local isBlock, data = turtle.inspectDown()
- if(isBlock)then
- if ( ( string.match(data.name, "croptopia:") or string.match(data.name, "wheat") or string.match(data.name, "potato") or string.match(data.name, "carrot"))and data['state']['age'] == 7) then
- turtle.digDown()
- for i = 6, 1, -1
- do
- turtle.suckDown()
- end
- seedIndex = getSeedIndex()
- if(seedIndex ~= nil) then
- turtle.select(seedIndex)
- turtle.placeDown()
- end
- end
- else
- seedIndex = getSeedIndex()
- if(seedIndex ~= nil) then
- turtle.digDown()
- turtle.select(seedIndex)
- turtle.placeDown()
- end
- end
- end
- -- If there is enough fuel, run the code
- if(fuelLevel > fuelNeeded) then
- for a = 13, 1, -1
- do
- direction = not(direction)
- turtle.forward()
- getCrop()
- if(direction) then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- for b = 13-1, 1, -1
- do
- turtle.forward()
- getCrop()
- end
- if(direction) then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- turtle.turnRight()
- turtle.turnRight()
- for c = 13, 1, -1
- do
- turtle.forward()
- end
- if (directionNew == false) then
- turtle.turnLeft()
- for d = 13-1, 1, -1
- do
- turtle.forward()
- end
- turtle.turnLeft()
- else
- turtle.turnRight()
- for d = 13-1, 1, -1
- do
- turtle.forward()
- end
- turtle.turnRight()
- end
- -- Drops ALL the items gained from farming ( seeds and crops ) into chest below starting point
- for slot = 1, 16, 1
- do
- turtle.select(slot)
- turtle.dropDown(64)
- end
- -- Takes 8 items from the chest above it (MEANT TO TAKE COAL OR OTHER HIGH FUEL AMOUNT ITEM)
- turtle.suckUp(8)
- turtle.refuel(8)
- -- 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
- term.blit("Error - Turtle does not have enough fuel!", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "fffffffffffffffffffffffffffffffff")
- term.blit("Please refuel the turtle using a fuel item and using the refuel() command!", "66666666666666666666666666666666666666666666666666666666666666666666666666", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
Add Comment
Please, Sign In to add comment