Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- tree mining
- -- pastebin get qBzVgNSg
- -- sapling is provided by a "clickmachine" from same mod
- -- or any other player imitating block which does
- -- right clicks with items
- -- mine trees up to 7 height
- -- make a roof in height 8 to prevent oak trees from
- -- growing weird
- -- felling turtle required ( = turtle + diamond axe )
- -- fuel it before use
- -- put coal in the slot which is selected (u can c that)
- -- refuel( number of coals to eat from stack )
- -- i.e.: refuel( 1 ) -- eats 1 coal
- function GoUp()
- -- get the tree, go straight up
- -- clears the situation where after a chunk
- -- reload the bottom has a sapling and above it
- -- are logs. The sapling would never grow up.
- for i=1, 7 do
- if CheckSapling() == false then
- turtle.dig()
- end
- turtle.digUp()
- turtle.up()
- end
- end
- function CheckSapling()
- found = false
- local detect, what = turtle.inspect()
- if detect then
- local anfang, ende = string.find( what.name, "sapling", 1, true )
- if ( anfang ~= nil ) then
- found = true
- print( "Sapling detected "..what.name )
- end
- end
- return found
- end
- function WaitForTree()
- -- wait for tree
- loginfront = false
- while loginfront == false do
- sleep( 1 )
- detect, what = turtle.inspect()
- if detect then
- local anfang, ende = string.find( what.name, "_log", 1, true )
- if ( anfang ~= nil ) then
- loginfront = true
- print( "front log detected "..what.name )
- end
- end
- end
- end
- function TurnToTree()
- local detect, what, anfang, ende
- notfound = true
- while notfound do
- detect, what = turtle.inspect()
- if detect then
- anfang, ende = string.find( what.name, "sapling", 1, true )
- if anfang ~= nil then
- notfound = false
- end
- anfang, ende = string.find( what.name, "_log", 1, true )
- if anfang ~= nil then
- notfound = false
- end
- end
- if notfound then
- turtle.turnLeft()
- end
- end
- end
- function GoDown()
- local detect = false
- local what = ""
- local chestfound = false
- -- going down to surface, until chest
- -- leaves are ok and get digged
- print( "Going down and looking for chest" )
- while chestfound == false do
- for i = 1, 4 do
- turtle.turnLeft()
- if CheckSapling() == false then
- turtle.dig()
- end
- -- try to get extra saplings
- turtle.suck()
- turtle.suckDown()
- end
- detect, what = turtle.inspectDown()
- if detect then
- print( "down block= ".. what.name )
- if( what.name == "minecraft:chest" ) then
- -- everything ok
- print( "found my chest" )
- chestfound = true
- end
- local anfang, ende = string.find( what.name, "_leaves", 1, true )
- if anfang ~= nil then
- turtle.digDown()
- end
- end
- turtle.down()
- end
- end
- local detect, what
- local okay = true
- -- label your turtle ie "label set XFiles"
- if os.getComputerLabel() == nil then
- os.setComputerLabel("Baum")
- end
- -- copy this program to startup when its not "startup"
- -- to make it resistant against chunk reloads (ie return from nether)
- me = fs.getName( shell.getRunningProgram() )
- if( me ~= "startup") then
- print( "Overwriting startup with "..me )
- if( fs.exists("startup") ) then
- fs.delete("startup")
- end
- fs.copy( me, "startup" )
- end
- -- Init after Chunk reload (random position over chest)
- -- find the base (chest)
- GoDown()
- -- Face the tree / sapling
- TurnToTree()
- -- often after a reload there's a sapling but
- -- there are logs above it. The sapling never grows.
- -- Go up and dig everything away
- GoUp()
- -- Init finished
- -- main loop
- while true do
- GoDown()
- -- unload all slots to chest
- for i = 1, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- TurnToTree()
- WaitForTree()
- GoUp()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement