Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tool = peripheral.wrap("left")
- local Slots = {
- SHEARS = 1,
- BONE_MEAL = 4,
- PETALS= 13,
- FLOWERS = 16
- }
- -- places petal
- local function placePetal()
- turtle.select(Slots.PETALS)
- turtle.place()
- end
- -- bone meals 1 time
- local function boneMeal()
- turtle.select(Slots.BONE_MEAL)
- if tool.lookAtBlock() ~= nil then
- turtle.place()
- end
- end
- -- shears using automata
- local function shearFlower()
- turtle.select(Slots.SHEARS)
- tool.digBlock()
- turtle.suck()
- end
- -- dumps flowers
- local function dumpFlower()
- turtle.select(Slots.FLOWERS)
- turtle.dropUp()
- end
- -- main function
- local function main()
- placePetal()
- boneMeal()
- shearFlower()
- dumpFlower()
- end
- -- checks turtle supplies, returns false if out of any resource
- counter = 0
- local function checkSupplies()
- ready = true
- -- clears screen
- term.clear()
- term.setCursorPos(1,1)
- turtle.select(Slots.SHEARS)
- if turtle.getItemCount() == 0 then
- print("Shears Broke! Put new Shears in slot '" .. Slots.SHEARS .. "'")
- ready = false
- end
- turtle.select(Slots.BONE_MEAL)
- if turtle.getItemCount() <= 1 then
- -- request bonemeal
- print("Refill bonemeal in slot '" .. Slots.BONE_MEAL .. "'")
- ready = false
- end
- turtle.select(Slots.PETALS)
- if turtle.getItemCount() <= 0 then
- counter = counter+1
- print("Put petals to harvest in slot '" .. Slots.PETALS .. "'")
- if counter > 10 then
- ready = false
- end
- else
- counter = 0
- item = turtle.getItemDetail()
- for k,v in pairs(item) do
- if string.find(v, "double_flower") then
- turtle.dropUp()
- os.sleep(.2)
- end
- end
- end
- return ready
- end
- -- while loop
- while true do
- if checkSupplies() then
- main()
- else
- print("Waiting...")
- os.sleep(5)
- end
- end
Add Comment
Please, Sign In to add comment