Advertisement
hbar

Untitled

Nov 30th, 2013
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.56 KB | None | 0 0
  1.  
  2. local lampslot = 1
  3. local modemslot = 5
  4. local cableslot = 9
  5.  
  6.  
  7. local move = function(f)
  8.     if turtle.getFuelLevel() < 1 then
  9.         print("Low on fuel. Please add fuel to my inventory.")
  10.         while turtle.getFuelLevel() < 1 do
  11.             os.sleep(5)
  12.             print("Checking for fuel...")
  13.             shell.run("refuel all")
  14.         end
  15.     end
  16.     while not f() do
  17.         sleep(0.3)
  18.     end
  19.     sleep(0.1)
  20. end
  21.  
  22.  
  23. local assemble = function()
  24.     move(closer)
  25.     while turtle.getItemCount(lampslot) < 1 do
  26.         lampslot = lampslot + 1
  27.         if lampslot > 4 then
  28.             print("Out of Illuminators, please put more on the first row and press return.")
  29.             lampslot = 1
  30.             local e,c = os.pullEvent("key")
  31.             while c ~= 28 do
  32.                 e,c = os.pullEvent("key")
  33.             end
  34.         end
  35.     end
  36.     turtle.select(lampslot)
  37.     place()
  38.     click()
  39.     move(away)
  40.     while turtle.getItemCount(modemslot) < 1 do
  41.         modemslot = modemslot + 1
  42.         if modemslot > 8 then
  43.             print("Out of modems, please put more on the second row and press return.")
  44.             modemslot = 5
  45.             local e,c = os.pullEvent("key")
  46.             while c ~= 28 do
  47.                 e,c = os.pullEvent("key")
  48.             end
  49.         end
  50.     end
  51.     turtle.select(modemslot)
  52.     place()
  53.     while turtle.getItemCount(cableslot) < 1 do
  54.         cableslot = cableslot + 1
  55.         if cableslot > 12 then
  56.             print("Out of cable, please put more on the third row and press return.")
  57.             cableslot = 9
  58.             local e,c = os.pullEvent("key")
  59.             while c ~= 28 do
  60.                 e,c = os.pullEvent("key")
  61.             end
  62.         end
  63.     end
  64.     turtle.select(cableslot)
  65.     place()
  66.     click()
  67. end
  68.  
  69.  
  70. width,height = 16,16
  71. column,row = 1,height
  72.  
  73. ascend = turtle.up
  74. descend = turtle.down
  75. closer = turtle.forward
  76. away = turtle.back
  77. click = turtle.attack
  78. place = turtle.place
  79.  
  80. --[[
  81. ascend = turtle.forward
  82. descend = turtle.back
  83. closer = turtle.down
  84. away = turtle.back
  85. click = turtle.attackDown
  86. place = turtle.placeDown
  87. --]]
  88.  
  89.  
  90. print("Good to go!")
  91. print(string.format("The process will take around %f minutes to finish.",(2.5*height*width)/60))
  92. print("Press return to begin.")
  93. e,c = os.pullEvent("key")
  94. while c ~= 28 do
  95.     e,c = os.pullEvent("key")
  96. end
  97.  
  98. print("Starting...")
  99.  
  100. turtle.select(1)
  101. while true do
  102.     if column > width then break end
  103.     assemble()
  104.     while row > 1 do
  105.         move(ascend)
  106.         row = row - 1
  107.         assemble()
  108.     end
  109.     turtle.turnLeft()
  110.     move(turtle.forward)
  111.     turtle.turnRight()
  112.     column = column + 1
  113.     if column > width then break end
  114.     assemble()
  115.     while row < height do
  116.         move(descend)
  117.         row = row + 1
  118.         assemble()
  119.     end
  120.     turtle.turnLeft()
  121.     move(turtle.forward)
  122.     turtle.turnRight()
  123.     column = column + 1
  124. end
  125.  
  126. if width % 2 == 1 then
  127.     for i=1,height-1 do
  128.         move(descend)
  129.     end
  130. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement