Advertisement
shirkit

Rail

Apr 11th, 2013
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. local tArgs = {...}
  2. local length = tonumber(tArgs[1]) or 0
  3. local width = tonumber(tArgs[2]) or 0
  4.  
  5. local slot = 1
  6.  
  7. function doWork()
  8.     for i = 1, width, 1 do
  9.         for j = 1, length, 1 do
  10.             turtle.dig()
  11.             turtle.digDown()
  12.             place("down")
  13.             turtle.forward()
  14.         end
  15.        
  16.         turtle.digDown()
  17.         place("down")
  18.        
  19.         if ( i % 2 == 0 ) then
  20.             turtle.turnRight()
  21.         else
  22.             turtle.turnLeft()
  23.         end
  24.        
  25.         turtle.dig()
  26.         turtle.forward()
  27.         turtle.digDown()
  28.         place("down")
  29.        
  30.         turtle.dig()
  31.         turtle.forward()
  32.         turtle.digDown()
  33.         place("down")
  34.        
  35.         turtle.dig()
  36.         turtle.forward()
  37.        
  38.         if ( i % 2 == 0 ) then
  39.             turtle.turnRight()
  40.         else
  41.             turtle.turnLeft()
  42.         end
  43.        
  44.     end
  45. end
  46.  
  47. function place(dir)
  48.     if turtle.getItemCount(slot) == 1 then
  49.         if slot == 16 then
  50.             print("Put more blocks")
  51.             while turtle.getItemCount(slot) == 1 do
  52.                 sleep(1)
  53.             end
  54.             slot = 1
  55.         else
  56.             slot = slot + 1
  57.         end
  58.         turtle.select(slot)
  59.         place(dir)
  60.     end
  61.    
  62.     if dir == "up" then
  63.         turtle.placeUp()
  64.     elseif dir == "down" then
  65.         turtle.placeDown()
  66.     else
  67.         turtle.place()
  68.     end
  69.  
  70. end
  71. doWork()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement