Advertisement
shirkit

Rail2

Apr 11th, 2013
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 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.        
  11.             turtle.digDown()
  12.             turtle.down()
  13.            
  14.             turtle.turnLeft()
  15.             turtle.dig()
  16.             turtle.turnLeft()
  17.             turtle.turnLeft()
  18.             turtle.dig()
  19.             turtle.turnLeft()
  20.             turtle.up()
  21.            
  22.             place("down")
  23.            
  24.             turtle.dig()
  25.             turtle.forward()
  26.         end
  27.        
  28.         turtle.digDown()
  29.         place("down")
  30.        
  31.         if ( i % 2 == 0 ) then
  32.             turtle.turnRight()
  33.         else
  34.             turtle.turnLeft()
  35.         end
  36.        
  37.         turtle.dig()
  38.         turtle.forward()
  39.         turtle.digDown()
  40.         place("down")
  41.        
  42.         turtle.dig()
  43.         turtle.forward()
  44.         turtle.digDown()
  45.         place("down")
  46.        
  47.         turtle.dig()
  48.         turtle.forward()
  49.        
  50.         if ( i % 2 == 0 ) then
  51.             turtle.turnRight()
  52.         else
  53.             turtle.turnLeft()
  54.         end
  55.        
  56.     end
  57. end
  58.  
  59. function place(dir)
  60.     if turtle.getItemCount(slot) == 1 then
  61.         if slot == 16 then
  62.             print("Put more blocks")
  63.             while turtle.getItemCount(slot) == 1 do
  64.                 sleep(1)
  65.             end
  66.             slot = 1
  67.         else
  68.             slot = slot + 1
  69.         end
  70.         turtle.select(slot)
  71.         place(dir)
  72.     end
  73.    
  74.     if dir == "up" then
  75.         turtle.placeUp()
  76.     elseif dir == "down" then
  77.         turtle.placeDown()
  78.     else
  79.         turtle.place()
  80.     end
  81.  
  82. end
  83. doWork()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement