Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local blockExist, item
- local logCount=0
- if not fs.exists('drovosek') then
- error("There's no drovosek's program")
- end
- function selectItem(name)
- --check all inventory slots
- local item
- for slot=1,16 do
- item=turtle.getItemDetail(slot)
- if item~=nil and item['name']==name then
- turtle.select(slot)
- return true
- end
- end
- --couldn't find item
- return false
- end
- function selectEmptySlot()
- --loop through all slots
- for slot =1,16 do
- if turtle.getItemCount(slot) then
- turtle.select(slot)
- return true
- end
- end
- --couldn't find empty space
- return false
- end
- --launching of robo to work
- while true do
- if not selectItem('minecraft:sapling') then
- error('Out of saplings')
- end
- print('Planting...')
- --placing tree to grow it
- turtle.place()
- while true do
- blockExists, item=turtle.inspect()
- if blockExists and item['name']=='minecraft:sapling' then
- if not selectItem('minecraft:dye') then
- error('Out of bone meal')
- --wait 10sec for getting dye
- os.sleep(10)
- end
- print('Using bone meal...')
- turtle.place()
- else
- break
- end
- end
- selectEmptySlot()
- shell.run('drovosek')
- turtle.back()
- turtle.turnLeft()
- turtle.turnLeft()
- while selectItem('minecraft:log') do
- logCount=logCount+turtle.getItemCount()
- print('Total logs:'..logCount)
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement