Advertisement
readix

woodFarm

Feb 25th, 2021 (edited)
934
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.08 KB | None | 0 0
  1. local res = {}
  2. local tool = require"import"
  3. local log = require"log"
  4. local t = turtle
  5. local sens = 0 -- 0 face aux logs, 1: regarde a droite, -1 regarde a gauche
  6. local slotMax = 14
  7.  
  8. function res.ramasser()
  9.     t.select(16)
  10.     t.turnLeft()
  11.     t.suck()
  12.     tool.fd(slotMax )
  13.     t.turnLeft()
  14.     for i = 0,1 do --premiere descente
  15.         t.suck()
  16.         tool.fd(slotMax )
  17.     end
  18.     t.turnRight()
  19.     t.suck()
  20.     tool.fd(slotMax )
  21.     t.turnRight()
  22.     for i = 0,3 do --grosse remontée a gauche
  23.         t.suck()
  24.         tool.fd(slotMax )
  25.     end
  26.     t.turnRight()
  27.     t.suck()
  28.     tool.fd(slotMax )
  29.     for i = 0,2 do
  30.         t.suck()
  31.         t.turnRight()
  32.         t.suck()
  33.         t.turnLeft()
  34.         tool.fd(slotMax )
  35.     end
  36.     t.turnRight()
  37.     t.suck()
  38.     tool.fd(slotMax )
  39.     for i = 0,2 do
  40.         t.suck()
  41.         t.turnRight()
  42.         t.suck()
  43.         t.turnLeft()
  44.         tool.fd(slotMax )
  45.     end
  46.     t.turnRight()
  47.     for i= 0,1 do
  48.         t.suck()
  49.         tool.fd(slotMax )
  50.     end
  51.     t.turnRight()
  52.     t.suck()
  53.     tool.fd(slotMax )
  54.     t.select(1)
  55.     tuple, name = t.inspectDown()
  56.     if tuple then
  57.         if not string.find(name['name'], "cobblestone") then
  58.             error()
  59.         end
  60.     end
  61. end
  62.  
  63.  
  64.  
  65. function res.planter()
  66.     t.select(16)
  67.     if t.getItemCount(16)==0 then
  68.         error("plus de sappling")
  69.     end
  70.     t.place()
  71.     t.select(1)
  72. end
  73.  
  74. function res.tryLog()
  75.     tuple, name = t.inspectDown()
  76.     if tuple then
  77.         if string.find(name['name'], "cobblestone") then
  78.             if sens==1 then
  79.                 t.turnLeft()
  80.             end
  81.             if sens==-1 then
  82.                 t.turnRight()
  83.             end
  84.             if log.mineTree() then
  85.                 res.ramasser()
  86.                 res.planter()
  87.             else
  88.                 res.planter()
  89.             end
  90.             if sens==-1 then
  91.                 t.turnLeft()
  92.             end
  93.             if sens==1 then
  94.                 t.turnRight()
  95.             end
  96.             if sens  ==0 then
  97.                 sens =1
  98.                 t.turnRight()
  99.             end
  100.             return
  101.         end
  102.     end
  103.     if sens  ==0 then
  104.         sens =1
  105.         t.turnRight()
  106.     end
  107. end
  108.  
  109. function res.changeDir()
  110.     tuple, name = t.inspect()
  111.     if tuple then
  112.         if string.find(name['name'], "torch") then
  113.             t.turnLeft()
  114.             t.turnLeft()
  115.             sens = -sens
  116.             sleep(180)
  117.         end
  118.     end
  119. end
  120.  
  121. function res.farm()
  122.    
  123.     while true do
  124.         res.tryLog()
  125.         res.changeDir()
  126.         tool.fd(slotMax )
  127.     end
  128. end
  129.  
  130.  
  131.  
  132. res.farm()
  133.  
  134.  
  135.  
  136.  
  137. return res
  138.    
  139.  
  140.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement