Advertisement
mishkapp

Turtle Cutter

Sep 30th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. args = { ... }
  2.  
  3. function forward()
  4.     while (true) do
  5.         if(not(turtle.detect())) then
  6.             turtle.attack()
  7.             turtle.forward()
  8.             return
  9.         end
  10.         turtle.attackUp()
  11.         turtle.digUp()
  12.        
  13.         turtle.up()
  14.     end
  15. end
  16.  
  17. function checkBlockToCut()
  18.     for i=1,args[2] do
  19.         turtle.select(i)
  20.         if(turtle.compareDown() or not(turtle.detectDown())) then
  21.             return true
  22.         end
  23.     end
  24.     return false
  25. end
  26.  
  27. function cut()
  28.     local downSteps = 0
  29.     while(checkBlockToCut()) do
  30.         turtle.attackDown()
  31.         turtle.digDown()
  32.  
  33.         turtle.down()
  34.         -- downSteps = downSteps + 1
  35.     end
  36.     -- for i=1,downSteps do
  37.     --  turtle.up()
  38.     -- end
  39. end
  40.  
  41. function run()
  42.     while (true) do
  43.         turtle.turnRight()
  44.         for i=1,args[1]-1 do
  45.             cut()
  46.             forward()      
  47.         end
  48.         cut()
  49.         turtle.turnLeft()
  50.         forward()
  51.  
  52.         turtle.turnLeft()
  53.         for i=1,args[1]-1 do
  54.             cut()
  55.             forward()      
  56.         end
  57.         cut()
  58.         turtle.turnRight()
  59.         forward()
  60.     end
  61. end
  62.  
  63. function init()
  64.     if (#args ~= 2) then
  65.         print("Usage: cutter [cutter width] [blocks to cut]")
  66.         os.exit()
  67.     end
  68.     -- cutterWidth = args[1]
  69.     -- blocksToCut = args[0]
  70. end
  71.  
  72. function main()
  73.     init()
  74.     run()
  75. end
  76.  
  77. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement