Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- logger
- -- Grows a tree, cuts it down.
- -- Stores the logs in a chest
- -- Written by HarvDad, March 2014
- args = {...}
- nArgs = #args
- version = "logger: Rev 2.1"
- saplingsSlot = 1
- sampleSlot = 16 -- This slot must have at least 1 sample of the correct log type
- bonemealSlot = 2
- y = 0
- if nArgs == 1 and args[1] == "help" then
- print(version)
- print("No arguments required")
- print("Place sapling supply in slot ", saplingsSlot)
- print("Place log sample in slot ", sampleSlot)
- print("Needs to be part of special tree farm")
- end
- function whackLeaves()
- turtle.dig()
- turtle.turnRight()
- turtle.dig()
- turtle.turnRight()
- turtle.dig()
- turtle.turnRight()
- turtle.dig()
- turtle.turnRight()
- end
- function focusSaplings()
- local i
- saplingCount = turtle.getItemCount(saplingsSlot)
- if saplingCount < 64 then
- -- print("Organizing saplings into slot ", saplingsSlot)
- for i=2,15 do
- turtle.select(i)
- if turtle.compareTo(saplingsSlot) then
- turtle.transferTo(saplingsSlot, 64-saplingCount)
- print("Transferred ", 64 - saplingCount, " saplings to slot ", saplingsSlot)
- saplingCount = turtle.getItemCount(saplingsSlot)
- if saplingCount >= 64 then
- turtle.select(saplingsSlot)
- break
- end
- end
- end
- end
- sampleCount = turtle.getItemCount(sampleSlot)
- if sampleCount > 1 then
- turtle.select(sampleSlot)
- turtle.dropDown(sampleCount - 1)
- end
- turtle.select(saplingsSlot)
- end
- function setFace(f)
- if f == 0 then
- if face == 0 then return end
- if face == 1 then right() return end
- if face == 2 then right() right() return end
- if face == 3 then left() return end
- end
- if f == 1 then
- if face == 0 then left() return end
- if face == 1 then return end
- if face == 2 then right() return end
- if face == 3 then right() right() return end
- end
- if f == 2 then
- if face == 0 then left() left() return end
- if face == 1 then left() return end
- if face == 2 then return end
- if face == 3 then right() return end
- end
- if f == 3 then
- if face == 0 then right() return end
- if face == 1 then left() left() return end
- if face == 2 then left() return end
- if face == 3 then return end
- end
- end
- function suckSaplings()
- for i=1,4 do
- turtle.suck()
- turtle.suckUp()
- turtle.turnRight()
- end
- setFace(0)
- end
- function dump()
- for i=3,15 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- turtle.dropDown()
- end
- end
- sampleCount = turtle.getItemCount(sampleSlot)
- if sampleCount > 1 then
- turtle.select(sampleSlot)
- turtle.dropDown(sampleCount - 1)
- end
- turtle.select(saplingsSlot)
- end
- function tryBonemeal()
- if turtle.getItemCount(bonemealSlot) > 1 then
- turtle.select(bonemealSlot)
- turtle.place()
- end
- end
- intervalLength = 30
- interval = 0
- print("Logging is enabled")
- while true do
- turtle.select(saplingsSlot)
- turtle.place()
- tryBonemeal()
- turtle.select(sampleSlot)
- repeat
- sleep(2)
- if interval > intervalLength then
- focusSaplings()
- interval = 0
- else
- interval = interval + 1
- end
- tryBonemeal()
- turtle.select(sampleSlot)
- until turtle.compare()
- turtle.dig()
- turtle.forward()
- turtle.select(2)
- while turtle.detectUp() do
- turtle.digUp()
- turtle.up()
- end
- while not turtle.detectDown() do
- turtle.suckDown()
- turtle.down()
- end
- suckSaplings()
- turtle.back()
- suckSaplings()
- dump()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement