Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Pumpkin Farmer V0.1 by QQII
- --Declerations
- local length = 0
- local width = -1
- --Functions
- local function refuel()
- while turtle.getFuelLevel() <= 0 do
- shell.run("refuel", "all")
- if turtle.getFuelLevel() <= 0 then
- print("ERROR: out of fuel")
- read()
- end
- end
- end
- local function forward() --Moves forward
- refuel()
- while not turtle.forward() do
- while not turtle.dig() do
- turtle.attack()
- end
- end
- end
- local function digDown() --Digs down
- if turtle.detectDown() then
- while not turtle.digDown() do
- turtle.attackDown()
- end
- end
- end
- local function line(l) --Harvests a line of l
- for i = 1, l do
- forward()
- digDown()
- end
- forward()
- end
- local function clearSlot(slotNumber) --Attemps to clear the slot slotNumber
- if turtle.getItemCount(slotNumber) ~= 0 then
- turtle.select(slotNumber)
- if not turtle.drop() then
- print("ERROR: failure to clear slot number " .. slotNumber)
- end
- end
- end
- local function clearSlots() --Places all the items into the chest infront of the turtle
- for i = 1,16 do
- if turtle.getItemCount(i) ~= 0 then
- clearSlot(i)
- end
- end
- end
- --User Inputs
- print("The turtle will harvest a a pumpkin or melon farm")
- if length < 1 then
- io.write("Length: ")
- while length <= 0 do
- length = tonumber(read())
- end
- end
- if width < 0 then
- io.write("Width: ")
- while width <= 0 do
- width = tonumber(read())
- end
- end
- --Main Script
- refuel()
- while true do
- clearSlots()
- os.sleep(length * 30)
- for i = 1, 2 do
- turtle.turnRight()
- line(width)
- turtle.turnRight()
- line(length)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement