Arphahat

Stairs

Mar 10th, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. turnDistance = 256
  2. depth = 256
  3. local tArgs = { ... }
  4. if (#tArgs == 1) then
  5.     depth = tonumber(tArgs[1])
  6. elseif (#tArgs == 2) then
  7.     depth = tonumber(tArgs[1])
  8.     turnDistance = tonumber(tArgs[2])
  9. end
  10.  
  11. function digStairs()
  12.     success = true
  13.     while turtle.detect()==true do
  14.         success = turtle.dig()
  15.     end
  16.    
  17.     while success and turtle.forward() == false do -- takes care of gravel falling in the way
  18.         success = turtle.dig()
  19.     end
  20.    
  21.     while success and turtle.detectUp()==true do
  22.         success = turtle.digUp()
  23.     end
  24.    
  25.     while success and turtle.detect()==true do
  26.         success = turtle.dig()
  27.     end
  28.    
  29.     while success and turtle.detectDown()==true do
  30.         success= turtle.digDown()
  31.     end    
  32.     if success then
  33.         turtle.down()      
  34.     end
  35.  
  36.      return success
  37. end
  38. i = 0
  39. while digStairs()==true and i <depth do
  40.     i = i + 1
  41.     if i % turnDistance == 0 then
  42.         turtle.dig()
  43.         turtle.up()
  44.         turtle.dig()
  45.         turtle.forward()
  46.         turtle.digUp()
  47.         turtle.turnLeft()
  48.         turtle.dig()
  49.         turtle.forward()
  50.         turtle.digUp()
  51.         turtle.digDown()
  52.         turtle.turnLeft()
  53.         turtle.dig()
  54.         turtle.forward()
  55.         turtle.digUp()
  56.         turtle.digDown()
  57.         turtle.down()
  58.     end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment