Advertisement
Guest User

test

a guest
Nov 25th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.93 KB | None | 0 0
  1. local blockName = "log"
  2.  
  3. function check()
  4.   local success, data = turtle.inspect()
  5.   if success then
  6.   if string.match(data.name,blockName) then
  7.     return true
  8.   end
  9.   print(data.name)
  10.   end
  11.   return false
  12. end
  13.  
  14. function moveLeft()
  15.   turtle.turnLeft()
  16.   turtle.forward()
  17.   turtle.forward()
  18.   turtle.turnRight()
  19. end
  20.  
  21. function moveRight()
  22.   turtle.turnRight()
  23.   turtle.forward()
  24.   turtle.forward()
  25.   turtle.turnLeft()
  26. end
  27.  
  28. function harvest()
  29.   m=0
  30.   if check() then
  31.     turtle.dig()
  32.     turtle.forward()
  33.     --local data = turtle.inspectUp()
  34.     while turtle.detectUp() do
  35.       if m > 5 then
  36.         break
  37.       end
  38.       turtle.digUp()
  39.       turtle.up()
  40.       m=m+1
  41.     end
  42.     while  not turtle.detectDown() do
  43.       turtle.down()
  44.     end
  45.     turtle.back()
  46.     turtle.select(16)
  47.     turtle.place()
  48.     turtle.select(1)
  49.   end
  50. end
  51.  
  52. function forward()
  53.   turtle.turnLeft()
  54.   turtle.forward()
  55.   turtle.turnRight()
  56.   turtle.forward()
  57.   turtle.forward()
  58.   turtle.turnRight()
  59.   turtle.forward()
  60.   turtle.turnLeft()  
  61. end
  62.  
  63. function contains(str,key)
  64.   if string.match(str,key) then
  65.     return true
  66.   end
  67.   return false
  68. end
  69.  
  70. function backToStart()
  71.   turtle.turnRight()
  72.   turtle.forward()
  73.   turtle.turnRight()
  74.   for i=0,12 do
  75.     turtle.forward()
  76.   end
  77.   for i=1,16 do
  78.     turtle.select(i)
  79.     turtle.drop()
  80.   end
  81.   turtle.select(1)
  82.   turtle.turnRight()
  83.   turtle.forward()
  84.   turtle.turnLeft()
  85.   for i=1,16 do
  86.     turtle.select(i)
  87.     turtle.drop()
  88.   end
  89.   turtle.select(16)
  90.   turtle.suck()
  91.   turtle.select(1)
  92.   turtle.turnRight()
  93.   turtle.turnRight()
  94.   turtle.forward()
  95. end
  96.    
  97.  
  98. function farm()
  99.   for k=0,2 do
  100.     for i=0,6 do
  101.       harvest()
  102.       moveLeft()
  103.       harvest()
  104.     end
  105.     forward()
  106.     for i=0,6 do
  107.       harvest()
  108.       moveRight()
  109.       harvest()
  110.     end
  111.     forward()
  112.   end
  113.   backToStart()
  114. end
  115.  
  116. while true do  
  117.   farm()
  118. end
  119. --backToStart()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement