moverperfect

XbyX

Jan 26th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. local arg = {...}
  2. if arg == nil then
  3.         print("Usage: 6x6 <forward> <right> <down>")
  4.         return 2
  5. end
  6.  
  7. z = tonumber (arg[1])
  8. x = tonumber (arg[2])
  9. y = tonumber (arg[3])
  10.  
  11.  
  12.  
  13. function checkInv()
  14.     for i=1,16 do
  15.         if turtle.getItemCount(i) == 0 then
  16.             print("Slot number "..i.." is empty, returning")
  17.             return
  18.         end
  19.     end
  20.     turtle.select(16)
  21.     turtle.placeUp()
  22.     for q=1,15 do
  23.         turtle.select(q)
  24.         turtle.dropUp()
  25.     end
  26.     turtle.select(1)
  27.    
  28. end
  29.  
  30. function dig(x)
  31.     for i=1,x do
  32.     turtle.digDown()
  33.     turtle.forward()
  34.     turtle.digDown()
  35.     checkInv()
  36.     end
  37. end
  38.  
  39. for i=1,y do
  40.     print("Starting level: "..i)
  41.     for o=1,x do
  42.         print("Starting row: "..o)
  43.         if o == x then
  44.             dig(z-1)
  45.         elseif o%2 == 0 then
  46.             dig(z-1)
  47.             turtle.turnLeft()
  48.             dig(1)
  49.             turtle.turnLeft()
  50.         else
  51.             dig(z-1)
  52.             turtle.turnRight()
  53.             dig(1)
  54.             turtle.turnRight()
  55.         end
  56.     end
  57.     if i==y then
  58.         print("Finished")
  59.     elseif x%2 == 1  then
  60.         turtle.turnRight()
  61.         turtle.turnRight()
  62.         turtle.down()
  63.     elseif x%2 == 0 then
  64.         turtle.turnRight()
  65.         turtle.turnRight()
  66.         turtle.down()
  67.         dig(z-1)
  68.         turtle.turnRight()
  69.         turtle.turnRight()             
  70.     end
  71.  
  72. end
Advertisement
Add Comment
Please, Sign In to add comment