Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- brokenTrees = 0
- function clearMonitor ()
- term.clear()
- term.setCursorPos(1,1)
- end
- function centerCursor(strSize)
- local x, y = term.getCursorPos()
- local width, height = term.getSize()
- term.setCursorPos(math.floor((width - strSize) / 2) + 1, y)
- end
- function checkTree ()
- local has_block, data = turtle.inspect()
- if data.name == "ars_nouveau:red_archwood_log" then
- return true
- else
- return false
- end
- end
- function sendPulse ()
- redstone.setOutput("back", true)
- os.sleep(0.5)
- redstone.setOutput("back", false)
- end
- function getSaplings ()
- while (not turtle.suckDown() and not lookForSaplings()) do
- clearMonitor()
- print("No saplings found. Checking again...")
- end
- updateMonitor()
- end
- function lookForSaplings ()
- for i=1, 16 do
- turtle.select(i)
- local currentItem = turtle.getItemDetail(i)
- if currentItem ~= nil then
- if (currentItem.name == "ars_nouveau:red_archwood_sapling") then
- return true
- end
- end
- end
- return false
- end
- function updateMonitor ()
- titleString = "===== Tree Farmer MK I ====="
- clearMonitor()
- centerCursor(#titleString)
- print(titleString)
- print("\nHi! I'm the Tree Farmer, courtesy of Bongo!\n")
- print("Please do not take items from me or the chest under me.\n\n")
- print("Trees harvested today: " .. brokenTrees)
- end
- updateMonitor ()
- while (true) do
- if checkTree() then
- brokenTrees = brokenTrees + 1
- sendPulse()
- os.sleep(3)
- getSaplings()
- turtle.place()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment