Advertisement
Guest User

lesFerm

a guest
Oct 16th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.52 KB | None | 0 0
  1. local blockExist, item
  2. local logCount=0
  3. if not fs.exists('drovosek') then
  4.   error("There's no drovosek's program")
  5. end
  6.  
  7. function selectItem(name)
  8.   --check all inventory slots
  9.   local item
  10.   for slot=1,16 do
  11.     item=turtle.getItemDetail(slot)
  12.     if item~=nil and item['name']==name then
  13.       turtle.select(slot)
  14.       return true
  15.     end  
  16.   end
  17.   --couldn't find item
  18.   return false
  19. end
  20.  
  21.  
  22. function selectEmptySlot()
  23.   --loop through all slots
  24.   for slot =1,16 do
  25.     if turtle.getItemCount(slot) then
  26.       turtle.select(slot)
  27.       return true
  28.     end  
  29.   end
  30.   --couldn't find empty space
  31.   return false
  32. end
  33.  
  34.  
  35. --launching of robo to work
  36. while true do
  37.   if not selectItem('minecraft:sapling') then
  38.     error('Out of saplings')
  39.   end
  40.  
  41.   print('Planting...')
  42.  
  43.   --placing tree to grow it
  44.   turtle.place()
  45.  
  46.   while true do
  47.     blockExists, item=turtle.inspect()
  48.     if blockExists and item['name']=='minecraft:sapling' then
  49.       if not selectItem('minecraft:dye') then
  50.         error('Out of bone meal')
  51.         --wait 10sec for getting dye
  52.         os.sleep(10)
  53.       end
  54.       print('Using bone meal...')
  55.       turtle.place()
  56.     else
  57.       break
  58.     end
  59.   end    
  60.  
  61.   selectEmptySlot()
  62.   shell.run('drovosek')
  63.  
  64.   turtle.back()
  65.   turtle.turnLeft()
  66.   turtle.turnLeft()
  67.  
  68.   while selectItem('minecraft:log') do
  69.       logCount=logCount+turtle.getItemCount()
  70.       print('Total logs:'..logCount)
  71.       turtle.drop()  
  72.    
  73.   end
  74.  
  75.   turtle.turnLeft()
  76.   turtle.turnLeft()
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement