Advertisement
bueddl

Untitled

Jun 3rd, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. local function checkFuel( )
  2.     write("Checking fuel level...")
  3.     if turtle.getFuelLevel() < 20 then
  4.         print("need refuel.")
  5.         for i=1,16 do
  6.             turtle.select(i)
  7.             if turtle.refuel(turtle.getItemCount(i)) then
  8.                 write("Fueled from slot ")
  9.                 print(i)
  10.             end
  11.  
  12.             if turtle.getFuelLevel() >= 500 then
  13.                 return
  14.             end
  15.            
  16.         end
  17.     else
  18.         print("fuel status is ok.")
  19.     end
  20. end
  21.  
  22. local function goToGround( )
  23.     write("goToGround...")
  24.     while turtle.detectDown() == false do
  25.         turtle.down()
  26.     end
  27.     print("ok")
  28. end
  29.  
  30. local function makeCorridoor( length )
  31.     goToGround()
  32.     write("makeCorridoor")
  33.  
  34.     for i=1,length,1 do
  35.         write(".");
  36.         turtle.dig()
  37.         turtle.down()
  38.         turtle.dig()
  39.         turtle.up()
  40.         turtle.forward()
  41.     end
  42.     print("done")
  43. end
  44.  
  45. local function makeCorridoorReturn( length )
  46.     makeCorridoor(length)
  47.  
  48.     for i=1,length,1 do
  49.         turtle.back()
  50.     end
  51. end
  52.  
  53. local function makeMatrix( rows, cols )
  54.     local coord, size
  55.     coord = {}
  56.     size  = {}
  57.  
  58.     coord.x = 0
  59.     coord.y = 0
  60.  
  61.     size.x  = 2 * rows + 1
  62.     size.y  = 2 * cols + 1
  63.    
  64.     print("Cols...")
  65.     for i=1,cols,1 do
  66.         checkFuel()
  67.         write("i=")
  68.         print(i)
  69.         makeCorridoorReturn( size.x )
  70.  
  71.         turtle.turnRight()
  72.         makeCorridoor(2)
  73.         turtle.turnLeft()
  74.     end
  75.  
  76.     turtle.turnRight()
  77.     turtle.turnRight()
  78.    
  79.     for i=0,size.y,1 do
  80.         turtle.forward()
  81.     end
  82.  
  83.     turtle.turnRight()
  84.  
  85.     print("Rows...")
  86.     for i=1,rows,1 do
  87.         checkFuel()
  88.         write("i=")
  89.         print(i)
  90.         makeCorridoorReturn( size.y )
  91.  
  92.         turtle.turnLeft()
  93.         makeCorridoor(2)
  94.         turtle.turnRight()
  95.     end
  96. end
  97.  
  98. makeMatrix( 10, 10 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement