Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---@diagnostic disable: lowercase-global
- -- Getting fuel level
- local fuelLevel = turtle.getFuelLevel()
- -- Getting GPS coordinates
- local x1, y1, z1 = gps.locate()
- -- Asking user for length and width
- print("How far do you want the turtle to go in front")
- local length = io.read()
- print("How far do you want the turtle to go to the side")
- local width = io.read()
- -- Asking for direction
- print("Would you like the turtle to go left (after it moves one forward) ONLY TYPE 'True' OR 'False'")
- local direction = io.read()
- local directionNew = direction
- -- Getting fuel needed
- local fuelNeeded = (length*width) + 1 + (1/2*length) + (1/2*width)
- -- 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) then
- if (string.match(item.name, "seed")) then
- return slot
- end
- 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:") and data['state']['age'] == 7) then
- turtle.digDown()
- for i = 6, 1, -1
- do
- turtle.suckDown()
- seedIndex = getSeedIndex()
- if(seedIndex ~= nil) then
- turtle.select(seedIndex)
- turtle.placeDown()
- end
- end
- end
- else
- seedIndex = getSeedIndex()
- if(seedIndex ~= nil) then
- turtle.select(seedIndex)
- turtle.placeDown()
- end
- end
- end
- if(fuelLevel > fuelNeeded) then
- for a = length, 1, -1
- do
- direction = not(direction)
- turtle.forward()
- getCrop()
- if(direction) then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- for b = width-1, 1, -1
- do
- turtle.forward()
- getCrop()
- end
- if(direction) then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- turtle.turnRight()
- turtle.turnRight()
- for c = length, 1, -1
- do
- turtle.forward()
- end
- if (directionNew == false) then
- turtle.turnLeft()
- for d = width-1, 1, -1
- do
- turtle.forward()
- end
- turtle.turnLeft()
- else
- turtle.turnRight()
- for d = width-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 a = 1, 16, 1
- do
- turtle.select(a)
- turtle.dropDown(64)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement