Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wood_id = "minecraft:spruce_log"
- sapling_id = "minecraft:spruce_sapling"
- dirt_id = "minecraft:dirt"
- grass_id = "minecraft:grass_block"
- sleep_time = 5
- function FindItemSlot (item_id)
- for i = 1, 16, 1 do
- turtle.select(i)
- local data = turtle.getItemDetail()
- if data then
- if data.name == item_id then
- return i
- end
- end
- end
- return -1
- end
- function PlantTree ()
- slot = FindItemSlot(sapling_id)
- turtle.select(slot)
- turtle.place()
- end
- function ReturnToStart ()
- local ground_level = false
- while not ground_level do
- local _, data = turtle.inspectDown()
- if data.name == dirt_id or data.name == grass_id then
- ground_level = true
- else
- while turtle.detectDown() do
- turtle.digDown()
- end
- turtle.down()
- end
- end
- end
- function ChopTree ()
- tree_exists = true
- while tree_exists do
- local _, data = turtle.inspect()
- if data.name == wood_id then
- turtle.dig()
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.up()
- else
- tree_exists = false
- end
- end
- ReturnToStart()
- PlantTree()
- end
- while true do
- local _, data = turtle.inspect()
- if data.name == wood_id then
- ChopTree()
- else
- os.sleep(sleep_time)
- end
- end
Add Comment
Please, Sign In to add comment