skypop

lumber

Sep 8th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- http://pastebin.com/4HLi33cn
  2. f,u,d=false,false,false
  3.  
  4. function look()
  5.   print("look")
  6.   local test,data = turtle.inspect()
  7.   f = test and data or false
  8.   test,data = turtle.inspectUp()
  9.   u = test and data or false
  10.   test,data = turtle.inspectDown()
  11.   d = test and data or false
  12. end
  13.  
  14. function step()
  15.   print("step")
  16.   look()
  17.   if d and (
  18.     d.name=="minecraft:stone"
  19.     or d.name=="minecraft:dirt"
  20.     or d.name=="minecraft:grass"
  21.   )
  22.   and not f then
  23.     print("plant sapling")
  24.     turtle.select(1)
  25.     turtle.place()
  26.   elseif f and f.name=="minecraft:sapling" then
  27.     print("drop bonemill")
  28.     turtle.select(2)
  29.     turtle.place()
  30.   elseif f and f.name=="minecraft:log" then
  31.     print("Cutting")
  32.     turtle.select(5)
  33.     turtle.dig()
  34.     turtle.digUp()
  35.     turtle.up()
  36.   elseif not f or f.name~="minecraft:log"
  37.   and not d then
  38.     print("landing")
  39.     turtle.down()
  40.   end
  41. end
  42.  
  43. function main()
  44.   local timer = os.startTimer(.5)
  45.   while true do
  46.     local e,k = os.pullEvent()
  47.     if e=="key" and k==keys.t then
  48.       break
  49.     elseif e=="timer" then
  50.       step()
  51.       timer = os.startTimer(.5)
  52.     end
  53.   end
  54. end
  55.  
  56.  
  57. main()
Add Comment
Please, Sign In to add comment