Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Turtle for harvesting Pam's Harvestcraft tree "fruits" (almonds,oranges,figs..).
- --Place Turtle infront of fruit, place a TORCH in the last slot.
- --The Turtle will drop any fruit collected bellow (chest etc).]]
- -- X are Fruits, T = turtle, C = chest, R = refuel Chest
- -- Think hight
- -- x x x x (H = 2)
- -- x x x x (Place T infront of left most X and chest under) Height = 1
- -- R C (H = ground)
- -- https://i.imgur.com/OkK10p1.png (Basic setup shown)
- print("Welcome to Jiron's Pam harvest Turtle")
- print("Remember to place a torch in the last slot")
- print("Width of the farm in ODD numbers only!")
- re = io.read()
- width = tonumber(re)
- print("Height of farm?")
- rel = io.read()
- height = tonumber(rel)
- print("Farm size set to " .. width .. "x" .. height)
- print("Cycle time? in minutes")
- print("https://i.imgur.com/OkK10p1.png")
- print("Shows basic setup")
- redir = io.read()
- --Farm
- waitTime = tonumber(redir * 60)
- age_metadata = 2 --metadata = 2 means the fruits are mature
- tUP = true
- start = true
- count = 0
- start = true
- function noFaithInUser(number)
- if height < 1 then
- height = 1
- end
- if (number % 2 == 0) then
- print("Error: Width is not odd in size!")
- return true
- end
- start = false
- return flase
- end
- function detectGrowth()
- if turtle.detectUp() == true then
- turtle.digUp()
- end
- if turtle.detect() then
- local suc, t = turtle.inspect()
- if suc and t.metadata == age_metadata then
- turtle.select(16)
- turtle.place()
- turtle.suck()
- count = count + 1
- print("Item count: ", count)
- --sendItemToStorage()
- end
- end
- end
- function sendItemToStorage()
- for i = 1, 15 do -- loop through the slots
- turtle.select(i)-- change to the slot
- turtle.dropDown()
- end
- end
- function refuelTurtle()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.suckDown()
- for i = 1, 15 do -- loop through the slots
- turtle.select(i)-- change to the slot
- if turtle.refuel(0) then -- if it's valid fuel
- turtle.refuel()-- consume half the stack as fuel
- end
- end
- sendItemToStorage()
- turtle.forward()
- turtle.turnLeft()
- end
- function UpOrDown()
- if tUP == true then
- moveUp(height - 1)
- tUP = false
- else
- moveDown(height - 1)
- tUP = true
- end
- end
- function run()
- for newWidth = width, 1, -1 do
- turtle.select(16)
- if height > 0 then
- if newWidth == width then
- UpOrDown()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- detectGrowth()
- else
- UpOrDown()
- if newWidth > 1 then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- detectGrowth()
- end
- end
- else
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- detectGrowth()
- end
- if newWidth == 1 then
- returnToStart()
- end
- end
- end
- function moveUp(h)
- if h >= 1 then
- detectGrowth()
- turtle.up()
- detectGrowth()
- h = h - 1
- moveUp(h)
- end
- end
- function moveDown(h)
- if h >= 1 then
- detectGrowth()
- turtle.down()
- detectGrowth()
- h = h - 1
- moveDown(h)
- end
- end
- function move(length)
- if length >= 0 then
- turtle.forward()
- length = length - 1
- move(length)
- end
- end
- function returnToStart()
- turtle.turnLeft()
- move(width - 2)
- turtle.turnRight()
- UpOrDown()
- end
- while true do
- if start == true then
- if noFaithInUser(width) == true then
- break
- end
- end
- if height == 0 then
- detectGrowth()
- sendItemToStorage()
- sleep(waitTime)
- else
- detectGrowth()
- run()
- sendItemToStorage()
- refuelTurtle()
- sleep(waitTime)--checks every 60s
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement