Guest User

lumber

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