Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Request for Project: Always revert back to previous selected slot after changing it
- x=14
- z=16
- CounterTrees = 0
- function hugoCutTree()
- CounterTrees = CounterTrees + 1
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- PlaceDownSafe(1)
- local counter = 0
- while turtle.detectUp() do
- turtle.digUp()
- if turtle.up() then counter = counter + 1 end
- end
- while counter > 0 do
- turtle.digDown()
- if turtle.down() then counter = counter - 1 end
- end
- PlaceDownSafe(1)
- end
- function PlaceDownSafe( Min )
- if turtle.getItemCount( 16 ) > Min then
- turtle.placeDown()
- return true
- else
- return false
- end
- end
- function TreeTile()
- turtle.forward()
- turtle.suckDown()
- end
- function CobbleTile()
- if turtle.detect() then hugoCutTree() else turtle.forward(); PlaceDownSafe(1) end
- turtle.suckDown()
- end
- function Tile()
- if TileSwitch == true then
- TreeTile()
- TileSwitch = false
- else
- CobbleTile()
- TileSwitch = true
- end
- end
- while true do
- --print("Let me chop chop trees!")
- --os.pullEvent("char")
- --print("CHOP CHOP nom nom nom....")
- TileSwitch = false
- statsCountTrees = {}
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- turtle.suck(64)
- turtle.refuel(64)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.up()
- turtle.turnLeft()
- turtle.select(16) -- Careful!
- Tile()
- --TODO: Reful me, feed me, master! (CHECK)
- for i=1,z do
- for j=1,x do Tile() end
- if i < z then
- if i%2 == 0 then turtle.turnLeft() else turtle.turnRight() end
- Tile()
- if i%2 == 0 then turtle.turnLeft() else turtle.turnRight() end
- else
- Tile()
- if i%2 == 1 then turtle.turnLeft() else turtle.turnRight() end
- for j=1,z-1 do Tile() end
- end
- end
- turtle.down()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,15 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(16)
- term.clear()
- print("Finished, Master, chopped ", CounterTrees, " trees :)")
- statsCountTrees[table.maxn(statsCountTrees)+1] = CounterTrees
- CounterTrees = 0
- do
- local sum = 0
- local avg = 0
- for i,v in ipairs(statsCountTrees) do sum = sum + v end
- avg = sum / table.maxn(statsCountTrees)
- print("Statistics for you:")
- print("Total: ",sum)
- print("Average: ",avg)
- print("Fuel: ",turtle.getFuelLevel())
- end
- --print("")
- --print("Press anything to pause me in next 10sec...")
- --os.timer(10)
- --local event, param = os.pullEvent()
- --if param < "timer" then
- --print("Paused!!! Press anything to continue...")
- --os.pullEvent()
- --end
- end
Advertisement
Add Comment
Please, Sign In to add comment