Advertisement
eduinus

waller2.lua

Oct 15th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 57.41 KB | None | 0 0
  1. local robot = require("robot")
  2. local term = require("term")
  3. local os = require("os")
  4. local component = require("component")
  5. local sides = require("sides")
  6. local keyboard = require("keyboard")
  7. local computer = require("computer")
  8.  
  9. function tableLength(table)
  10.   count = 1
  11.   while table[count] ~= nil do
  12.     count=count+1
  13.   end
  14.   return count-1
  15. end
  16.  
  17. function testLeft()
  18.     leftPresent = false
  19.     robot.turnLeft()
  20.     if robot.detect() then
  21.         leftPresent = true
  22.     end
  23.     robot.turnRight()
  24.     return leftPresent
  25. end
  26.  
  27. function move()
  28.     swung = false
  29.     while robot.detect() do
  30.         robot.select(1) robot.swing()
  31.     swung = true
  32.     invCount = robot.inventorySize() -- check if need to dump garbage
  33.     if component.inventory_controller.getStackInInternalSlot(1) ~= nil then
  34.       robot.select(1)
  35.       while component.inventory_controller.getStackInInternalSlot(invCount) ~= nil and (robot.compareTo(invCount) == false or component.inventory_controller.getStackInInternalSlot(invCount).size == component.inventory_controller.getStackInInternalSlot(invCount).maxSize) do
  36.         if invCount == itemArray[tableLength(itemArray)][1]+1 then
  37.           robot.select(4) robot.place()
  38.             for x=itemArray[tableLength(itemArray)][1]+1, robot.inventorySize() do
  39.               robot.select(x)
  40.               while robot.drop() == false do end
  41.             end
  42.           robot.select(4) robot.swing()
  43.           invCount = robot.inventorySize()
  44.         else invCount = invCount - 1
  45.         end
  46.       end
  47.       robot.select(1)
  48.       robot.transferTo(invCount)
  49.     end
  50.     end
  51.  
  52.     if computer.energy() / computer.maxEnergy() <= 0.025 then
  53.         while computer.energy() / computer.maxEnergy() <= 0.975 do
  54.             if component.generator.count() < 1 then -- refuel
  55.                 print("Refueling!")
  56.                 robot.select(4) robot.place() robot.select(1)
  57.             while component.generator.count() < 64 do robot.suck(64-component.generator.count()) component.generator.insert() end
  58.             robot.select(4) robot.swing()
  59.             end
  60.             print("Charging... "..computer.energy())
  61.             os.sleep(10)
  62.         end
  63.         print("Charged: "..computer.energy())
  64.     end
  65.    
  66.     while robot.forward() ~= true do end
  67.   return swung
  68. end
  69.  
  70. function moveUp()
  71.     swung = false
  72.     while robot.detectUp() do
  73.         robot.select(1) robot.swingUp()
  74.     swung = true
  75.     invCount = robot.inventorySize() -- check if need to dump garbage
  76.     if component.inventory_controller.getStackInInternalSlot(1) ~= nil then
  77.       robot.select(1)
  78.       while component.inventory_controller.getStackInInternalSlot(invCount) ~= nil and (robot.compareTo(invCount) == false or component.inventory_controller.getStackInInternalSlot(invCount).size == component.inventory_controller.getStackInInternalSlot(invCount).maxSize) do
  79.         if invCount == itemArray[tableLength(itemArray)][1]+1 then
  80.           robot.select(4) robot.placeUp()
  81.             for x=itemArray[tableLength(itemArray)][1]+1, robot.inventorySize() do
  82.               robot.select(x)
  83.               while robot.dropUp() == false do end
  84.             end
  85.           robot.select(4) robot.swingUp()
  86.           invCount = robot.inventorySize()
  87.         else invCount = invCount - 1
  88.         end
  89.       end
  90.       robot.select(1)
  91.       robot.transferTo(invCount)
  92.     end
  93.     end
  94.  
  95.     if computer.energy() / computer.maxEnergy() <= 0.025 then
  96.         while computer.energy() / computer.maxEnergy() <= 0.975 do
  97.             if component.generator.count() < 1 then -- refuel
  98.                 print("Refueling!")
  99.                 robot.select(4) robot.placeUp() robot.select(1)
  100.             while component.generator.count() < 64 do robot.suckUp(64-component.generator.count()) component.generator.insert() end
  101.             robot.select(4) robot.swingUp()
  102.             end
  103.             print("Charging... "..computer.energy())
  104.             os.sleep(10)
  105.         end
  106.         print("Charged: "..computer.energy())
  107.     end
  108.  
  109.     while robot.up() ~= true do end
  110.   return swung
  111. end
  112.  
  113. function moveDown()
  114.     swung = false
  115.     while robot.detectDown() do
  116.         robot.select(1) robot.swingDown()
  117.     swung = true
  118.     invCount = robot.inventorySize() -- check if need to dump garbage
  119.     if component.inventory_controller.getStackInInternalSlot(1) ~= nil then
  120.       robot.select(1)
  121.       while component.inventory_controller.getStackInInternalSlot(invCount) ~= nil and (robot.compareTo(invCount) == false or component.inventory_controller.getStackInInternalSlot(invCount).size == component.inventory_controller.getStackInInternalSlot(invCount).maxSize) do
  122.         if invCount == itemArray[tableLength(itemArray)][1]+1 then
  123.           robot.select(4) robot.placeDown()
  124.             for x=itemArray[tableLength(itemArray)][1]+1, robot.inventorySize() do
  125.               robot.select(x)
  126.               while robot.dropDown() == false do end
  127.             end
  128.           robot.select(4) robot.swingDown()
  129.           invCount = robot.inventorySize()
  130.         else invCount = invCount - 1
  131.         end
  132.       end
  133.       robot.select(1)
  134.       robot.transferTo(invCount)
  135.     end
  136.     end
  137.    
  138.     if computer.energy() / computer.maxEnergy() <= 0.025 then
  139.         while computer.energy() / computer.maxEnergy() <= 0.975 do
  140.             if component.generator.count() < 1 then -- refuel
  141.                 print("Refueling!")
  142.                 robot.select(4) robot.placeDown() robot.select(1)
  143.             while component.generator.count() < 64 do robot.suckDown(64-component.generator.count()) component.generator.insert() end
  144.             robot.select(4) robot.swingDown()
  145.             end
  146.             print("Charging... "..computer.energy())
  147.             os.sleep(10)
  148.         end
  149.         print("Charged: "..computer.energy())
  150.     end
  151.    
  152.     while robot.down() ~= true do end
  153.   return swung
  154. end
  155.  
  156. function moveBack()
  157.     swung = false
  158.     if robot.back() ~= true then
  159.         robot.turnAround()
  160.         swung = true
  161.         robot.select(1)
  162.         while robot.detect() do
  163.             robot.swing()
  164.             os.sleep(0.2)
  165.         invCount = robot.inventorySize() -- check if need to dump garbage
  166.         if component.inventory_controller.getStackInInternalSlot(1) ~= nil then
  167.             robot.select(1)
  168.             while component.inventory_controller.getStackInInternalSlot(invCount) ~= nil and (robot.compareTo(invCount) == false or component.inventory_controller.getStackInInternalSlot(invCount).size == component.inventory_controller.getStackInInternalSlot(invCount).maxSize) do
  169.                 if invCount == itemArray[tableLength(itemArray)][1]+1 then
  170.                     robot.select(4) robot.place()
  171.                     for x=itemArray[tableLength(itemArray)][1]+1, robot.inventorySize() do
  172.                         robot.select(x)
  173.                         while robot.drop() == false do end
  174.                     end
  175.                     robot.select(4) robot.swing()
  176.                     invCount = robot.inventorySize()
  177.                 else
  178.                     invCount = invCount - 1
  179.                 end
  180.             end
  181.             robot.select(1)
  182.             robot.transferTo(invCount)
  183.         end
  184.         end
  185.     end
  186.  
  187.     if computer.energy() / computer.maxEnergy() <= 0.025 then
  188.         while computer.energy() / computer.maxEnergy() <= 0.975 do
  189.             if component.generator.count() < 1 then -- refuel
  190.                 print("Refueling!")
  191.                 robot.select(4) robot.place() robot.select(1)
  192.             while component.generator.count() < 64 do robot.suck(64-component.generator.count()) component.generator.insert() end
  193.             robot.select(4) robot.swing()
  194.             end
  195.             print("Charging... "..computer.energy())
  196.             os.sleep(10)
  197.         end
  198.         print("Charged: "..computer.energy())
  199.     end
  200.    
  201.     if swung == true then
  202.         robot.turnAround()
  203.         while robot.back() ~= true do end
  204.     end
  205.     return swung
  206. end
  207.  
  208. function dig()
  209.   while robot.detect() do
  210.         robot.select(1) robot.swing()
  211.     invCount = robot.inventorySize() -- check if need to dump garbage
  212.     if component.inventory_controller.getStackInInternalSlot(1) ~= nil then
  213.       while component.inventory_controller.getStackInInternalSlot(invCount) ~= nil and (robot.compareTo(invCount) == false or component.inventory_controller.getStackInInternalSlot(invCount).size == component.inventory_controller.getStackInInternalSlot(invCount).maxSize) do
  214.         if invCount == itemArray[tableLength(itemArray)][1]+1 then
  215.           robot.select(4) robot.place()
  216.             for x=itemArray[tableLength(itemArray)][1]+1, robot.inventorySize() do
  217.               robot.select(x)
  218.               while robot.drop() == false do end
  219.             end
  220.           robot.select(4) robot.swing()
  221.           invCount = robot.inventorySize()
  222.         else invCount = invCount - 1
  223.         end
  224.       end
  225.       robot.select(1)
  226.       robot.transferTo(invCount)
  227.     end
  228.     end
  229.  
  230.     if computer.energy() / computer.maxEnergy() <= 0.025 then
  231.         while computer.energy() / computer.maxEnergy() <= 0.975 do
  232.             if component.generator.count() < 1 then -- refuel
  233.                 print("Refueling!")
  234.                 robot.select(4) robot.place() robot.select(1)
  235.             while component.generator.count() < 64 do robot.suck(64-component.generator.count()) component.generator.insert() end
  236.             robot.select(4) robot.swing()
  237.             end
  238.             term.clearLine()
  239.             print("Charging... "..computer.energy())
  240.             os.sleep(10)
  241.         end
  242.         print("Charged: "..computer.energy())
  243.     end
  244. end
  245.  
  246. function digDown()
  247.     while robot.detectDown() do
  248.         robot.select(1) robot.swingDown()
  249.     invCount = robot.inventorySize() -- check if need to dump garbage
  250.     if component.inventory_controller.getStackInInternalSlot(1) ~= nil then
  251.       while component.inventory_controller.getStackInInternalSlot(invCount) ~= nil and (robot.compareTo(invCount) == false or component.inventory_controller.getStackInInternalSlot(invCount).size == component.inventory_controller.getStackInInternalSlot(invCount).maxSize) do
  252.         if invCount == itemArray[tableLength(itemArray)][1]+1 then
  253.           robot.select(4) robot.placeDown()
  254.             for x=itemArray[tableLength(itemArray)][1]+1, robot.inventorySize() do
  255.               robot.select(x)
  256.               while robot.dropDown() == false do end
  257.             end
  258.           robot.select(4) robot.swingDown()
  259.           invCount = robot.inventorySize()
  260.         else invCount = invCount - 1
  261.         end
  262.       end
  263.       robot.select(1)
  264.       robot.transferTo(invCount)
  265.     end
  266.     end
  267.  
  268.     if computer.energy() / computer.maxEnergy() <= 0.025 then
  269.         while computer.energy() / computer.maxEnergy() <= 0.975 do
  270.             if component.generator.count() < 1 then -- refuel
  271.                 print("Refueling!")
  272.                 robot.select(4) robot.placeDown() robot.select(1)
  273.             while component.generator.count() < 64 do robot.suckDown(64-component.generator.count()) component.generator.insert() end
  274.             robot.select(4) robot.swingDown()
  275.             end
  276.             print("Charging... "..computer.energy())
  277.             os.sleep(10)
  278.         end
  279.         print("Charged: "..computer.energy())
  280.     end
  281. end
  282.  
  283. function digUp()
  284.     while robot.detectUp() do
  285.         robot.select(1) robot.swingUp()
  286.     invCount = robot.inventorySize() -- check if need to dump garbage
  287.     if component.inventory_controller.getStackInInternalSlot(1) ~= nil then
  288.       while component.inventory_controller.getStackInInternalSlot(invCount) ~= nil and (robot.compareTo(invCount) == false or component.inventory_controller.getStackInInternalSlot(invCount).size == component.inventory_controller.getStackInInternalSlot(invCount).maxSize) do
  289.         if invCount == itemArray[tableLength(itemArray)][1]+1 then
  290.           robot.select(4) robot.placeUp()
  291.             for x=itemArray[tableLength(itemArray)][1]+1, robot.inventorySize() do
  292.               robot.select(x)
  293.               while robot.dropUp() == false do end
  294.             end
  295.           robot.select(4) robot.swingUp()
  296.           invCount = robot.inventorySize()
  297.         else invCount = invCount - 1
  298.         end
  299.       end
  300.       robot.select(1)
  301.       robot.transferTo(invCount)
  302.     end
  303.     end
  304.  
  305.     if computer.energy() / computer.maxEnergy() <= 0.025 then
  306.         while computer.energy() / computer.maxEnergy() <= 0.975 do
  307.             if component.generator.count() < 1 then -- refuel
  308.                 print("Refueling!")
  309.                 robot.select(4) robot.placeUp() robot.select(1)
  310.             while component.generator.count() < 64 do robot.suckUp(64-component.generator.count()) component.generator.insert() end
  311.             robot.select(4) robot.swingUp()
  312.             end
  313.             print("Charging... "..computer.energy())
  314.             os.sleep(10)
  315.         end
  316.         print("Charged: "..computer.energy())
  317.     end
  318. end
  319.  
  320. function relocate(initPos, endPos) -- moves robot from given side to other side (starting facing out and ending facing out)
  321. -- move to South
  322.     if initPos == "N" then
  323.         robot.turnLeft()
  324.         move()
  325.         robot.turnLeft()
  326.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  327.         move()
  328.         robot.turnLeft()
  329.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  330.         robot.turnRight()
  331.     end
  332.     if initPos == "E" then
  333.         robot.turnRight()
  334.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  335.         robot.turnRight()
  336.         move()
  337.         robot.turnLeft()
  338.     end
  339.     if initPos == "S" then
  340.         -- already here
  341.     end
  342.     if initPos == "W" then
  343.         robot.turnLeft()
  344.         move()
  345.         robot.turnLeft()
  346.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  347.         robot.turnRight()
  348.     end
  349.     if initPos == "NE" then
  350.         moveBack()
  351.         robot.turnRight()
  352.         moveBack()
  353.         robot.turnRight()
  354.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  355.         robot.turnRight()
  356.         move()
  357.         robot.turnLeft()
  358.     end
  359.     if initPos == "SE" then
  360.         moveBack()
  361.         robot.turnRight()
  362.         moveBack()
  363.         -- we here
  364.     end
  365.     if initPos == "SW" then
  366.         moveBack()
  367.         robot.turnRight()
  368.         moveBack()
  369.         robot.turnLeft()
  370.         move()
  371.         robot.turnLeft()
  372.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  373.         robot.turnRight()
  374.     end
  375.     if initPos == "NW" then
  376.         moveBack()
  377.         robot.turnRight()
  378.         moveBack()
  379.         robot.turnLeft()
  380.         move()
  381.         robot.turnLeft()
  382.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  383.         move()
  384.         robot.turnLeft()
  385.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  386.         robot.turnRight()
  387.     end
  388. -- move from South
  389.     if endPos == "N" then
  390.         robot.turnLeft()
  391.         move()
  392.         robot.turnLeft()
  393.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  394.         move()
  395.         robot.turnLeft()
  396.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  397.         robot.turnRight()
  398.     end
  399.     if endPos == "E" then
  400.         robot.turnLeft()
  401.         move()
  402.         robot.turnLeft()
  403.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  404.         robot.turnRight()
  405.     end
  406.     if endPos == "S" then
  407.         -- already here
  408.     end
  409.     if endPos == "W" then
  410.         robot.turnRight()
  411.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  412.         robot.turnRight()
  413.         move()
  414.         robot.turnLeft()
  415.     end
  416.     if endPos == "NE" then
  417.         robot.turnLeft()
  418.         move()
  419.         robot.turnLeft()
  420.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  421.         robot.turnRight()
  422.         move()
  423.         robot.turnLeft()
  424.         move()
  425.     end
  426.     if endPos == "SE" then
  427.         -- we here
  428.         move()
  429.         robot.turnLeft()
  430.         move()
  431.     end
  432.     if endPos == "SW" then
  433.         robot.turnRight()
  434.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  435.         robot.turnRight()
  436.         move()
  437.         robot.turnLeft()
  438.         move()
  439.         robot.turnLeft()
  440.         move()
  441.     end
  442.     if endPos == "NW" then
  443.         robot.turnLeft()
  444.         move()
  445.         robot.turnLeft()
  446.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  447.         move()
  448.         robot.turnLeft()
  449.         if move() then move() robot.turnAround() place("ladder") robot.turnAround() else move() end
  450.         robot.turnRight()
  451.         move()
  452.         robot.turnLeft()
  453.         move()
  454.     end
  455. end
  456.  
  457. function straightJut()
  458.     move()
  459.     move()
  460.     robot.turnRight()
  461.     placeDown("plank")
  462.     move()
  463.     placeDown("plank")
  464.     robot.turnLeft()
  465.     move()
  466.     robot.turnRight()
  467.     move()
  468.     placeDown("stoneBrick")
  469.     moveBack()
  470.     place("spruceFence")
  471.     placeDown("plank")
  472.     moveBack()
  473.     placeDown("plank")
  474.     moveBack()
  475.     placeDown("stoneBrick")
  476.     robot.turnRight()
  477.     moveBack()
  478.     place("spruceFence")
  479.     robot.turnRight()
  480.     placeDown("stoneBrick")
  481.     moveBack()
  482.     place("spruceFence")
  483.     placeDown("stoneBrick")
  484.     moveBack()
  485.     placeDown("stoneBrick")
  486.     moveBack()
  487.     placeDown("stoneBrick")
  488.     robot.turnLeft()
  489.     moveBack()
  490.     place("spruceFence")
  491.     robot.turnLeft()
  492.     placeUp("log")
  493.     moveBack()
  494.     digUp()
  495.     place("log")
  496.     moveBack()
  497.     digUp()
  498.     moveBack()
  499.     placeUp("log")
  500.     robot.turnRight()
  501.     moveBack()
  502.     place("log")
  503.     moveUp()
  504.     moveUp()
  505.     move()
  506.     move()
  507.     placeDown("torch")
  508.     moveBack()
  509.     robot.turnRight()
  510.     placeUp("sprucePlank")
  511.     moveBack()
  512.     place("log")
  513.     placeUp("sprucePlank")
  514.     moveBack()
  515.     placeUp("sprucePlank")
  516.     moveBack()
  517.     placeUp("sprucePlank")
  518.     robot.turnLeft()
  519.     move()
  520.     placeDown("torch")
  521.     moveBack()
  522.     moveBack()
  523.     place("log")
  524.     robot.turnRight()
  525.     for i=1, 3 do move() end
  526.     moveDown()
  527.     moveDown()
  528. end
  529.  
  530. function diagJut()
  531.     move()
  532.     placeDown("plank")
  533.     move()
  534.     placeDown("plank")
  535.     move()
  536.     placeDown("stoneBrick")
  537.     robot.turnRight()
  538.     moveBack()
  539.     place("spruceFence")
  540.     placeDown("stoneBrick")
  541.     robot.turnRight()
  542.     moveBack()
  543.     place("spruceFence")
  544.     robot.turnRight()
  545.     moveBack()
  546.     placeDown("stoneBrick")
  547.     placeUp("torch")
  548.     moveBack()
  549.     place("spruceFence")
  550.     placeUp("log")
  551.     robot.turnRight()
  552.     moveBack()
  553.     place("log")
  554.     placeDown("stoneBrick")
  555.     moveBack()
  556.     placeDown("plank")
  557.     moveBack()
  558.     placeDown("plank")
  559.     robot.turnLeft()
  560.     moveBack()
  561.     robot.turnLeft()
  562.     move()
  563.     placeDown("stoneBrick")
  564.     moveBack()
  565.     place("spruceFence")
  566.     placeDown("stoneBrick")
  567.     moveBack()
  568.     place("spruceFence")
  569.     placeDown("stoneBrick")
  570.     moveBack()
  571.     digUp()
  572.     robot.turnRight()
  573.     moveBack()
  574.     robot.turnRight()
  575.     moveBack()
  576.     placeUp("log")
  577.     moveBack()
  578.     place("log")
  579.     placeDown("stoneBrick")
  580.     moveUp()
  581.     placeDown("spruceFence")
  582.     moveUp()
  583.     placeDown("torch")
  584.     move()
  585.     placeUp("sprucePlank")
  586.     robot.turnAround()
  587.     moveBack()
  588.     place("log")
  589.     robot.turnRight()
  590.     move()
  591.     placeUp("sprucePlank")
  592.     robot.turnRight()
  593.     move()
  594.     robot.turnLeft()
  595.     move()
  596.     placeUp("sprucePlank")
  597.     moveBack()
  598.     place("log")
  599.     moveDown()
  600.     moveDown()
  601. end
  602.  
  603. itemArray = {}
  604.     -- SLOT 1 FOR PICK (ideally infinipick)
  605.     itemArray[1] = {} itemArray[1][1] = 6 itemArray[1][2] = 2 itemArray[1][3] = 9 itemArray[1][4] = "stoneBrick" -- stone tesseract
  606.     itemArray[2] = {} itemArray[2][1] = 17 itemArray[2][2] = 3 itemArray[2][3] = 9 itemArray[2][4] = "stoneSlab" -- misc tesseract 1
  607.     itemArray[3] = {} itemArray[3][1] = 18 itemArray[3][2] = 3 itemArray[3][3] = 10 itemArray[3][4] = "torch" -- misc tesseract 2
  608.     itemArray[4] = {} itemArray[4][1] = 19 itemArray[4][2] = 3 itemArray[4][3] = 11 itemArray[4][4] = "plank" -- misc tesseract 3
  609.     itemArray[5] = {} itemArray[5][1] = 20 itemArray[5][2] = 3 itemArray[5][3] = 12 itemArray[5][4] = "plankSlab" -- misc tesseract 4
  610.     itemArray[6] = {} itemArray[6][1] = 21 itemArray[6][2] = 3 itemArray[6][3] = 13 itemArray[6][4] = "ironDoor" -- misc tesseract 5
  611.     itemArray[7] = {} itemArray[7][1] = 22 itemArray[7][2] = 3 itemArray[7][3] = 14 itemArray[7][4] = "ironWindow" -- misc tesseract 6 -frameless
  612.     itemArray[8] = {} itemArray[8][1] = 23 itemArray[8][2] = 3 itemArray[8][3] = 15 itemArray[8][4] = "button" -- misc tesseract 7
  613.     itemArray[9] = {} itemArray[9][1] = 24 itemArray[9][2] = 3 itemArray[9][3] = 16 itemArray[9][4] = "ladder" -- misc tesseract 8
  614.     -- NB SLOT 4 FOR COAL COKE OR OTHER FUEL TELE
  615.     itemArray[10] = {} itemArray[10][1] = 25 itemArray[10][2] = 5 itemArray[10][3] = 9 itemArray[10][4] = "log" -- misc 2 tesseract 1
  616.     itemArray[11] = {} itemArray[11][1] = 26 itemArray[11][2] = 5 itemArray[11][3] = 10 itemArray[11][4] = "sprucePlank" -- misc 2 tesseract 2
  617.     itemArray[12] = {} itemArray[12][1] = 27 itemArray[12][2] = 5 itemArray[12][3] = 11 itemArray[12][4] = "spruceFence" -- misc 2 tesseract 3
  618.     itemArray[13] = {} itemArray[13][1] = 28 itemArray[13][2] = 5 itemArray[13][3] = 12 itemArray[13][4] = "trapDoor" -- misc 2 tesseract 4
  619.  
  620. function place(blockName)
  621.     swung = false
  622.     while robot.detect() do -- check for blockage
  623.         robot.select(1) robot.swing()
  624.         swung = true
  625.     invCount = robot.inventorySize() -- check if need to dump garbage
  626.     if component.inventory_controller.getStackInInternalSlot(1) ~= nil then
  627.       while component.inventory_controller.getStackInInternalSlot(invCount) ~= nil and (robot.compareTo(invCount) == false or component.inventory_controller.getStackInInternalSlot(invCount).size == component.inventory_controller.getStackInInternalSlot(invCount).maxSize) do
  628.         if invCount == itemArray[tableLength(itemArray)][1]+1 then
  629.           robot.select(4) robot.place()
  630.             for x=itemArray[tableLength(itemArray)][1]+1, robot.inventorySize() do
  631.               robot.select(x)
  632.               while robot.drop() == false do end
  633.             end
  634.           robot.select(4) robot.swing()
  635.           invCount = robot.inventorySize()
  636.         else invCount = invCount - 1
  637.         end
  638.       end
  639.       robot.select(1)
  640.       robot.transferTo(invCount)
  641.     end
  642.     end
  643.  
  644.     for blocki=1, tableLength(itemArray) do -- need to restock?
  645.         if itemArray[blocki][4] == blockName then
  646.             if component.inventory_controller.getStackInInternalSlot(itemArray[blocki][1]) == nil then
  647.                 if blockName ~= "stoneBrick" then
  648.                     robot.select(itemArray[blocki][2])
  649.                     robot.place()
  650.                     print("Restocking "..itemArray[blocki][4]..".")
  651.                     robot.select(itemArray[blocki][1])
  652.                     component.inventory_controller.suckFromSlot(3,itemArray[blocki][3],(component.inventory_controller.getSlotMaxStackSize(3,itemArray[blocki][3])-1))
  653.                     robot.select(itemArray[blocki][2]) robot.swing() os.sleep(0.2)
  654.                 else
  655.                     if itemArray[blocki][1]<16 then
  656.                         while component.inventory_controller.getStackInInternalSlot(itemArray[blocki][1]) == nil and itemArray[blocki][1]<16 do
  657.                             itemArray[blocki][1] = itemArray[blocki][1] + 1
  658.                         end
  659.                     else
  660.                         itemArray[blocki][1] = 6
  661.                         robot.select(itemArray[blocki][2])
  662.                         robot.place()
  663.                         print("Restocking "..itemArray[blocki][4]..".")
  664.                         for stonei=itemArray[blocki][1], 16 do
  665.                             robot.select(stonei)
  666.                             component.inventory_controller.suckFromSlot(3,9,64)
  667.                             while component.inventory_controller.getSlotStackSize(3,9)<component.inventory_controller.getSlotMaxStackSize(3,9) do os.sleep(1) end
  668.                         end
  669.                         robot.select(itemArray[blocki][2]) robot.swing() os.sleep(0.2)
  670.                     end
  671.                 end
  672.             end
  673.             robot.select(itemArray[blocki][1])
  674.         end
  675.     end
  676.    
  677.     if blockName == "ladder" then
  678.         if robot.place(3) == false then robot.place() end
  679.     else
  680.         if robot.place(0) == false then robot.place() end
  681.     end
  682.    
  683.     return swung
  684. end
  685.  
  686. function placeUp(blockName)
  687.     swung = false
  688.     while robot.detectUp() do -- check for blockage
  689.         robot.select(1) robot.swingUp()
  690.         swung = true
  691.     invCount = robot.inventorySize() -- check if need to dump garbage
  692.     if component.inventory_controller.getStackInInternalSlot(1) ~= nil then
  693.       while component.inventory_controller.getStackInInternalSlot(invCount) ~= nil and (robot.compareTo(invCount) == false or component.inventory_controller.getStackInInternalSlot(invCount).size == component.inventory_controller.getStackInInternalSlot(invCount).maxSize) do
  694.         if invCount == itemArray[tableLength(itemArray)][1]+1 then
  695.           robot.select(4) robot.placeUp()
  696.             for x=itemArray[tableLength(itemArray)][1]+1, robot.inventorySize() do
  697.               robot.select(x)
  698.               while robot.dropUp() == false do end
  699.             end
  700.           robot.select(4) robot.swingUp()
  701.           invCount = robot.inventorySize()
  702.         else invCount = invCount - 1
  703.         end
  704.       end
  705.       robot.select(1)
  706.       robot.transferTo(invCount)
  707.     end
  708.     end
  709.  
  710.     for blocki=1, tableLength(itemArray) do -- need to restock?
  711.       if itemArray[blocki][4] == blockName then
  712.         if component.inventory_controller.getStackInInternalSlot(itemArray[blocki][1]) == nil then
  713.           if blockName ~= "stoneBrick" then
  714.           robot.select(itemArray[blocki][2])
  715.           robot.placeUp()
  716.           print("Restocking "..itemArray[blocki][4]..".")
  717.           robot.select(itemArray[blocki][1])
  718.           component.inventory_controller.suckFromSlot(1,itemArray[blocki][3],(component.inventory_controller.getSlotMaxStackSize(1,itemArray[blocki][3])-1))
  719.           robot.select(itemArray[blocki][2]) robot.swingUp() os.sleep(0.2)
  720.         else
  721.           if itemArray[blocki][1]<16 then
  722.             while component.inventory_controller.getStackInInternalSlot(itemArray[blocki][1]) == nil and itemArray[blocki][1]<16 do
  723.               itemArray[blocki][1] = itemArray[blocki][1] + 1
  724.             end
  725.           else
  726.             itemArray[blocki][1] = 6
  727.             robot.select(itemArray[blocki][2])
  728.             robot.placeUp()
  729.             print("Restocking "..itemArray[blocki][4]..".")
  730.             for stonei=itemArray[blocki][1], 16 do
  731.               robot.select(stonei)
  732.               while component.inventory_controller.getSlotStackSize(1,9)<component.inventory_controller.getSlotMaxStackSize(1,9) do os.sleep(1) end
  733.               component.inventory_controller.suckFromSlot(1,9,64)
  734.             end
  735.           robot.select(itemArray[blocki][2]) robot.swingUp() os.sleep(0.2)
  736.           end
  737.         end
  738.         end
  739.       robot.select(itemArray[blocki][1])
  740.       end
  741.     end
  742.     if robot.placeUp(1) == false then robot.placeUp() end
  743.     return swung
  744. end
  745.  
  746. function placeDown(blockName)
  747.     swung = false
  748.     while robot.detectDown() do -- check for blockage
  749.         robot.select(1) robot.swingDown()
  750.         swung = true
  751.     invCount = robot.inventorySize() -- check if need to dump garbage
  752.     if component.inventory_controller.getStackInInternalSlot(1) ~= nil then
  753.       while component.inventory_controller.getStackInInternalSlot(invCount) ~= nil and (robot.compareTo(invCount) == false or component.inventory_controller.getStackInInternalSlot(invCount).size == component.inventory_controller.getStackInInternalSlot(invCount).maxSize) do
  754.         if invCount == itemArray[tableLength(itemArray)][1]+1 then
  755.           robot.select(4) robot.placeDown()
  756.             for x=itemArray[tableLength(itemArray)][1]+1, robot.inventorySize() do
  757.               robot.select(x)
  758.               while robot.dropDown() == false do end
  759.             end
  760.           robot.select(4) robot.swingDown()
  761.           invCount = robot.inventorySize()
  762.         else invCount = invCount - 1
  763.         end
  764.       end
  765.       robot.select(1)
  766.       robot.transferTo(invCount)
  767.     end
  768.     end
  769.  
  770.     for blocki=1, tableLength(itemArray) do -- need to restock?
  771.       if itemArray[blocki][4] == blockName then
  772.         if component.inventory_controller.getStackInInternalSlot(itemArray[blocki][1]) == nil then
  773.           if blockName ~= "stoneBrick" then
  774.           robot.select(itemArray[blocki][2])
  775.           robot.placeDown()
  776.           print("Restocking "..itemArray[blocki][4]..".")
  777.           robot.select(itemArray[blocki][1])
  778.           component.inventory_controller.suckFromSlot(0,itemArray[blocki][3],(component.inventory_controller.getSlotMaxStackSize(0,itemArray[blocki][3])-1))
  779.           robot.select(itemArray[blocki][2]) robot.swingDown() os.sleep(0.2)
  780.         else
  781.           if itemArray[blocki][1]<16 then
  782.             while component.inventory_controller.getStackInInternalSlot(itemArray[blocki][1]) == nil and itemArray[blocki][1]<16 do
  783.               itemArray[blocki][1] = itemArray[blocki][1] + 1
  784.             end
  785.           else
  786.             itemArray[blocki][1] = 6
  787.             robot.select(itemArray[blocki][2])
  788.             robot.placeDown()
  789.             print("Restocking "..itemArray[blocki][4]..".")
  790.             for stonei=itemArray[blocki][1], 16 do
  791.               robot.select(stonei)
  792.               while component.inventory_controller.getSlotStackSize(0,9)<component.inventory_controller.getSlotMaxStackSize(0,9) do os.sleep(1) end
  793.               component.inventory_controller.suckFromSlot(0,9,64)
  794.             end
  795.           robot.select(itemArray[blocki][2]) robot.swingDown() os.sleep(0.2)
  796.           end
  797.         end
  798.         end
  799.       robot.select(itemArray[blocki][1])
  800.       end
  801.     end
  802.     if blockName == "log" then
  803.         if robot.placeDown(3) == false then
  804.             if robot.placeDown(2) == false then
  805.                 robot.placeDown()
  806.             end
  807.         end
  808.     elseif blockName == "torch" then
  809.         torchI = 2
  810.         while torchI <=5 and robot.placeDown(torchI) == false do
  811.             torchI = torchI + 1
  812.         end
  813.         if torchI == 6 then
  814.             robot.placeDown()
  815.         end
  816.     else
  817.         if robot.placeDown(0) == false then
  818.             robot.placeDown()
  819.         end
  820.     end
  821.     return swung
  822. end
  823.  
  824. function multipleOf(wallStep, wallLength, wallIncline) -- see if i is a multiple of sectionLength/abs(sectionIncline) (rounded down/up) (for height)
  825.     if wallIncline == 0 then return false end
  826.     multCheckI = wallLength/(math.abs(wallIncline)+1)
  827.     multCheck = multCheckI
  828.     while multCheck<wallLength-1 do
  829.         if (wallStep-multCheck<1) and (wallStep-multCheck>=0) then
  830.             return true
  831.         end
  832.         multCheck = multCheck + multCheckI
  833.     end
  834. end
  835.  
  836. function doWindow()
  837.     robot.turnRight()
  838.     move()
  839.     moveUp()
  840.     for i=1, 3 do move() end
  841.     place("ironWindow")
  842.     robot.turnRight()
  843.     move()
  844.     robot.turnLeft()
  845.     place("ironWindow")
  846.     robot.turnLeft()
  847.     move()
  848.     robot.turnLeft()
  849.     for i=1, 3 do move() end
  850.     moveDown()
  851.     move()
  852.     robot.turnRight()
  853. end
  854.  
  855. function wallAccentTorch(wallStepIn)
  856.   if wallStepIn == 1 then return end
  857.   wallStep = wallStepIn - 1
  858.   while wallStep > 16 do
  859.     wallStep = wallStep - 16
  860.   end
  861.   if wallStep == 2 or wallStep == 6 or wallStep == 7 or wallStep == 10 or wallStep == 11 or wallStep == 15 then
  862.     moveUp()
  863.     place("stoneBrick")
  864.     moveDown()
  865.   end
  866.   if wallStep == 3 or wallStep == 14 then
  867.     moveUp()
  868.     place("stoneBrick")
  869.     moveDown()
  870.     placeUp("torch")
  871.   end
  872. end
  873.  
  874. function diagWallAccentTorch(wallStepIn)
  875.   if wallStepIn == 1 then return end
  876.   wallStep = wallStepIn - 1
  877.   while wallStep > 16 do
  878.     wallStep = wallStep - 16
  879.   end
  880.   if wallStep == 2 or wallStep == 6 or wallStep == 11 or wallStep == 15 then
  881.     moveUp()
  882.     place("stoneBrick")
  883.     moveDown()
  884.   end
  885.   if wallStep == 3 or wallStep == 14 or wallStep == 7 or wallStep == 10 then
  886.     moveUp()
  887.     place("stoneBrick")
  888.     moveDown()
  889.     placeUp("torch")
  890.   end
  891. end
  892.  
  893. function straightSlabs(incline) -- if multiple
  894.     robot.turnLeft()
  895.     move()
  896.     if incline >= 0 then moveUp() end
  897.     robot.turnLeft()
  898.     placeDown("stoneSlab")
  899.     move()
  900.     for i=1, 2 do
  901.         moveDown()
  902.         placeDown("stoneBrick")
  903.         moveUp()
  904.         placeDown("stoneSlab")
  905.         move()
  906.     end
  907.     placeDown("stoneSlab")
  908.     robot.turnAround()
  909.     move()
  910.     robot.turnRight()
  911.     move()
  912.     for i=1, 20 do
  913.         moveDown()
  914.     end
  915.     robot.turnAround()
  916.     move()
  917.     moveDown()
  918.     placeDown("plank")
  919.     moveUp()
  920.     placeDown("plankSlab")
  921.     robot.turnRight()
  922.     move()
  923.     moveDown()
  924.     placeDown("plank")
  925.     moveUp()
  926.     placeDown("plankSlab")
  927.     robot.turnRight()
  928.     move()
  929.     for i=1, 19 do
  930.         moveUp()
  931.     end
  932.     if incline < 0 then moveUp() end
  933.     robot.turnLeft()
  934.     move()
  935. end
  936.  
  937. function diagonalSlabs(incline) -- if multiple
  938.     robot.turnAround()
  939.     move()
  940.     if incline >= 0 then moveUp() end
  941.     robot.turnRight()
  942.     move()
  943.     robot.turnLeft()
  944.     placeDown("stoneSlab")
  945.     move()
  946.     for i=1, 5 do
  947.         moveDown()
  948.         placeDown("stoneBrick")
  949.         moveUp()
  950.         placeDown("stoneSlab")
  951.         move()
  952.     end
  953.     placeDown("stoneSlab")
  954.     robot.turnAround()
  955.     move()
  956.     robot.turnRight()
  957.     move()
  958.     for i=1, 20 do
  959.         moveDown()
  960.     end
  961.     robot.turnAround()
  962.     move()
  963.     robot.turnRight()
  964.     for i=1, 4 do
  965.         moveDown()
  966.         placeDown("plank")
  967.         moveUp()
  968.         placeDown("plankSlab")
  969.         move()
  970.     end
  971.     moveDown()
  972.     placeDown("plank")
  973.     moveUp()
  974.     placeDown("plankSlab")
  975.     robot.turnRight()
  976.     move()
  977.     robot.turnLeft()
  978.     for i=1, 19 do
  979.         moveUp()
  980.     end
  981.     if incline < 0 then moveUp() end
  982.     for i=1, 2 do move() end
  983. end
  984.  
  985. function straightLogs(wallStepIn) -- place on second side
  986.   if wallStepIn == 1 then return end
  987.   wallStep = wallStepIn - 1
  988.   while wallStep > 16 do
  989.     wallStep = wallStep - 16
  990.   end
  991.   if wallStep == 8 then
  992.     placeDown("log")
  993.     moveBack()
  994.     placeDown("log")
  995.     move()
  996.     robot.turnAround()
  997.     place("torch")
  998.     robot.turnAround()
  999.   end
  1000. end
  1001.  
  1002. function diagonalLogs(wallStepIn) -- place on opposite side!
  1003.   if wallStepIn == 1 then return end
  1004.   wallStep = wallStepIn - 1
  1005.   while wallStep > 16 do
  1006.     wallStep = wallStep - 16
  1007.   end
  1008.   if wallStep == 10 then
  1009.     robot.turnRight()
  1010.     moveBack()
  1011.     placeDown("stoneBrick")
  1012.     robot.turnAround()
  1013.     for i=1, 5 do
  1014.         moveBack()
  1015.         placeDown("log")
  1016.     end
  1017.     for i=1, 2 do
  1018.         move()
  1019.     end
  1020.     robot.turnRight()
  1021.     for i=1, 2 do
  1022.         moveBack()
  1023.         placeDown("log")
  1024.     end
  1025.     for i=1, 4 do
  1026.         move()
  1027.     end
  1028.     for i=1, 2 do
  1029.         placeDown("log")
  1030.         moveBack()
  1031.     end
  1032.     robot.turnRight()
  1033.     moveBack()
  1034.     place("torch")
  1035.     moveBack()
  1036.     robot.turnLeft()
  1037.   end
  1038. end
  1039.  
  1040. function internalTorch(wallStepIn)
  1041.   if wallStepIn == 1 then return end
  1042.   wallStep = wallStepIn - 1
  1043.   while wallStep > 16 do
  1044.     wallStep = wallStep - 16
  1045.   end
  1046.   if wallStep == 3 or wallStep == 14 then
  1047.     placeDown("torch")
  1048.   end
  1049. end
  1050.  
  1051. function diagInternalTorch(wallStepIn)
  1052.   if wallStepIn == 1 then return end
  1053.   wallStep = wallStepIn - 1
  1054.   while wallStep > 16 do
  1055.     wallStep = wallStep - 16
  1056.   end
  1057.   if wallStep == 3 or wallStep == 14 or wallStep == 7 or wallStep == 10 then
  1058.     placeDown("torch")
  1059.   end
  1060. end
  1061.  
  1062. function externalTorch(wallStepIn)
  1063.   if wallStepIn == 1 then return end
  1064.   wallStep = wallStepIn - 1
  1065.   while wallStep > 16 do
  1066.     wallStep = wallStep - 16
  1067.   end
  1068.   if wallStep == 3 or wallStep == 14 then
  1069.     move()
  1070.     if robot.detect() == false then
  1071.         move()
  1072.         placeDown("torch")
  1073.         moveBack()
  1074.     end
  1075.     moveBack()
  1076.   end
  1077. end
  1078.  
  1079. function diagExternalTorch(wallStepIn)
  1080.   if wallStepIn == 1 then return end
  1081.   wallStep = wallStepIn - 1
  1082.   while wallStep > 16 do
  1083.     wallStep = wallStep - 16
  1084.   end
  1085.   if wallStep == 3 or wallStep == 14 or wallStep == 7 or wallStep == 10 then
  1086.     move()
  1087.     if robot.detect() == false then
  1088.         move()
  1089.         placeDown("torch")
  1090.         moveBack()
  1091.     end
  1092.     moveBack()
  1093.   end
  1094. end
  1095.  
  1096. function externalTorchLow(wallStepIn)
  1097.   if wallStepIn == 1 then return end
  1098.   wallStep = wallStepIn - 1
  1099.   while wallStep > 16 do
  1100.     wallStep = wallStep - 16
  1101.   end
  1102.   if wallStep == 3 or wallStep == 14 then
  1103.     if robot.detect() == false then
  1104.         move()
  1105.         placeDown("torch")
  1106.         moveBack()
  1107.     end
  1108.   end
  1109. end
  1110.  
  1111. function diagExternalTorchLow(wallStepIn)
  1112.   if wallStepIn == 1 then return end
  1113.   wallStep = wallStepIn - 1
  1114.   while wallStep > 16 do
  1115.     wallStep = wallStep - 16
  1116.   end
  1117.   if wallStep == 3 or wallStep == 14 or wallStep == 7 or wallStep == 10 then
  1118.     if robot.detect() == false then
  1119.         move()
  1120.         placeDown("torch")
  1121.         moveBack()
  1122.     end
  1123.   end
  1124. end
  1125.  
  1126. function isOdd(number) -- only works for positive integers
  1127.     while number >= 0 do
  1128.         if number == 0 then
  1129.             return false
  1130.         end
  1131.         number = number - 2
  1132.     end
  1133.     if number < 0 then
  1134.         return true
  1135.     end
  1136. end
  1137.  
  1138. function roundDown(number)
  1139.     rd = 0
  1140.     while number >= 1 do
  1141.         rd = rd + 1
  1142.         number = number - 1
  1143.     end
  1144.     return rd
  1145. end
  1146.  
  1147. function straightEscapeHatch(wallLengthIn, wallStepIn)
  1148.     if wallStepIn == 1 then return end
  1149.     realWallStep = wallStepIn - 1
  1150.     realWallLength = wallLengthIn - 2
  1151.     realChunks = realWallLength/16
  1152.     if realChunks >=16 then
  1153.         hatches = ((realChunks-8)/8)
  1154.         extraChunks = 8 * (hatches - roundDown(hatches))
  1155.         if isOdd(extraChunks) then
  1156.             extraChunks = extraChunks - 1
  1157.         end
  1158.         checki = (extraChunks/2)*16
  1159.         for i=1, roundDown(hatches) do
  1160.             checki = checki + (16*8)
  1161.             if checki+10 == realWallStep then
  1162.                 moveBack()
  1163.                 for i=1, 19 do moveDown() end
  1164.                 robot.turnLeft()
  1165.                 for i=1, 2 do move() end
  1166.                 place("button")
  1167.                 robot.turnRight()
  1168.                 for i=1, 2 do move() end
  1169.                 robot.turnRight()
  1170.                 place("button")
  1171.                 robot.turnRight()
  1172.                 moveDown()
  1173.                 dig()
  1174.                 place("ironDoor")
  1175.                 for i=1, 2 do moveUp() end
  1176.                 move()
  1177.                 move()
  1178.                 robot.turnAround()
  1179.                 place("stoneBrick")
  1180.                 robot.turnAround()
  1181.                 move()
  1182.                 move()
  1183.                 move()
  1184.                 robot.turnAround()
  1185.                 moveDown()
  1186.                 dig()
  1187.                 moveDown()
  1188.                 dig()
  1189.                 place("ironDoor")
  1190.                 moveUp()
  1191.                 robot.turnLeft()
  1192.                 place("button")
  1193.                 robot.turnRight()
  1194.                 moveUp()
  1195.                 for i=1, 2 do move() end
  1196.                 robot.turnAround()
  1197.                 place("stoneBrick")
  1198.                 robot.turnAround()
  1199.                 move()
  1200.                 robot.turnRight()
  1201.                 move()
  1202.                 robot.turnLeft()
  1203.                 for i=1, 2 do moveDown() end
  1204.                 moveBack()
  1205.                 for i=1, 2 do
  1206.                     place("ladder")
  1207.                     moveUp()
  1208.                 end
  1209.                 placeDown("button")
  1210.                 for i=1, 16 do
  1211.                     place("ladder")
  1212.                     moveUp()
  1213.                 end
  1214.                 move()
  1215.                 moveUp()
  1216.                 place("button")
  1217.                 moveUp()
  1218.                 place("spruceFence")
  1219.                 placeDown("trapDoor")
  1220.                 robot.turnRight()
  1221.                 move()
  1222.                 robot.turnLeft()
  1223.                 move()
  1224.             end
  1225.         end
  1226.     end
  1227. end
  1228.  
  1229. function diagonalEscapeHatch(wallLengthIn, wallStepIn)
  1230.     if wallStepIn == 1 then return end
  1231.     realWallStep = wallStepIn - 1
  1232.     realWallLength = wallLengthIn - 2
  1233.     realChunks = realWallLength/16
  1234.     if realChunks >=16 then
  1235.         hatches = ((realChunks-8)/8)
  1236.         extraChunks = 8 * (hatches - roundDown(hatches))
  1237.         if isOdd(extraChunks) then
  1238.             extraChunks = extraChunks - 1
  1239.         end
  1240.         checki = (extraChunks/2)*16
  1241.         for i=1, roundDown(hatches) do
  1242.             checki = checki + (16*8)
  1243.             if checki+10 == realWallStep then
  1244.                 moveBack()
  1245.                 for i=1, 19 do moveDown() end
  1246.                 robot.turnLeft()
  1247.                 for i=1, 2 do move() end
  1248.                 robot.turnRight()
  1249.                 for i=1, 3 do move() end
  1250.                 robot.turnLeft()
  1251.                 place("button")
  1252.                 robot.turnAround()
  1253.                 place("stoneBrick")
  1254.                 moveDown()
  1255.                 place("stoneBrick")
  1256.                 moveDown()
  1257.                 place("stoneBrick")
  1258.                 moveUp()
  1259.                 placeDown("stoneBrick")
  1260.                 robot.turnLeft()
  1261.                 move()
  1262.                 robot.turnAround()
  1263.                 place("ironDoor")
  1264.                 moveUp()
  1265.                 robot.turnLeft()
  1266.                 place("button")
  1267.                 robot.turnRight()
  1268.                 moveUp()
  1269.                 move()
  1270.                 move()
  1271.                 robot.turnAround()
  1272.                 place("stoneBrick")
  1273.                 robot.turnAround()
  1274.                 for i=1, 5 do move() end
  1275.                 moveDown()
  1276.                 robot.turnLeft()
  1277.                 place("button")
  1278.                 robot.turnAround()
  1279.                 place("stoneBrick")
  1280.                 moveDown()
  1281.                 place("stoneBrick")
  1282.                 moveDown()
  1283.                 place("stoneBrick")
  1284.                 moveUp()
  1285.                 placeDown("stoneBrick")
  1286.                 robot.turnLeft()
  1287.                 move()
  1288.                 robot.turnAround()
  1289.                 place("ironDoor")
  1290.                 moveUp()
  1291.                 robot.turnLeft()
  1292.                 place("button")
  1293.                 robot.turnRight()
  1294.                 moveUp()
  1295.                 for i=1, 2 do move() end
  1296.                 robot.turnAround()
  1297.                 place("stoneBrick")
  1298.                 robot.turnAround()
  1299.                 for i=1, 2 do moveDown() end
  1300.                 robot.turnRight()
  1301.                 move()
  1302.                 robot.turnLeft()
  1303.                 for i=1, 2 do move() end
  1304.                 for i=1, 18 do
  1305.                     place("ladder")
  1306.                     moveUp()
  1307.                 end
  1308.                 move()
  1309.                 moveUp()
  1310.                 place("button")
  1311.                 moveUp()
  1312.                 place("spruceFence")
  1313.                 placeDown("trapDoor")
  1314.                 robot.turnRight()
  1315.                 move()
  1316.                 robot.turnLeft()
  1317.             end
  1318.         end
  1319.     end
  1320. end
  1321.  
  1322. -- Begin
  1323. term.clear()
  1324. print("Press space to confirm that robot is facing internal tower column, on the South side, on the right block.")
  1325. while not keyboard.isKeyDown(keyboard.keys.space) do os.sleep(0.1) end
  1326. term.clear()
  1327.  
  1328. -- Load Tower Information
  1329.  
  1330. print("Tower Data File:")
  1331. towerData = io.read()
  1332.  
  1333. towerArray = {}
  1334. towerNum = 0
  1335. first = true
  1336. for line in io.lines(towerData) do
  1337.     if first == false then
  1338.     wordNum = 0
  1339.     towerNum = towerNum +1
  1340.     towerArray[towerNum] = {}
  1341.     for word in string.gmatch(line, '([^,]+)') do
  1342.         wordNum = wordNum + 1
  1343.         if wordNum == 1 then towerArray[towerNum][wordNum] = tonumber(word) end -- tower North East nib X
  1344.         if wordNum == 2 then towerArray[towerNum][wordNum] = tonumber(word) end -- tower North East nib Y
  1345.         if wordNum == 3 then towerArray[towerNum][wordNum] = tonumber(word) end -- tower North East nib Z
  1346.         if wordNum == 4 then towerArray[towerNum][wordNum] = word end -- outgoing wall orientation e.g. N,NE,E,SE,S,SW,W,NW
  1347.         if wordNum == 5 then print("Tower Data is messed up. Exiting...") os.exit() end
  1348.     end
  1349.     else
  1350.         towerArray[0] = {}
  1351.         for word in string.gmatch(line, '([^,]+)') do
  1352.             towerArray[0][4] = word
  1353.         end
  1354.         first = false
  1355.     end
  1356. end
  1357.  
  1358. term.clear()
  1359. print("Tower Data loaded...")
  1360. print(" ")
  1361.  
  1362. os.sleep(1)
  1363. term.clear()
  1364.  
  1365. print("Robot Inventory Instructions:")
  1366. print("1 - Pickaxe (Preferably w/o Durability)")
  1367. print("2 - Stone Brick Transceiver")
  1368. print("3 - Misc. Transceiver")
  1369. print("4 - Trash/Fuel Transceiver")
  1370. print("5 - Misc. Transceiver 2")
  1371. print("6+ - No need to load!")
  1372.  
  1373. print(" ")
  1374. print("--- Press Enter When Ready to Begin ---")
  1375. while not keyboard.isKeyDown(keyboard.keys.enter) do os.sleep(0.1) end
  1376. term.clear()
  1377. robot.select(1)
  1378. component.inventory_controller.equip()
  1379. print("Building...")
  1380.  
  1381. -- Begin walling sequence
  1382.  
  1383. for towerIt=1, 1 do
  1384.  
  1385.     -- Calculate wall section lengths
  1386.     if towerArray[towerIt][4] == "N" or towerArray[towerIt][4] == "S" or towerArray[towerIt][4] == "NE" or towerArray[towerIt][4] == "NW" or towerArray[towerIt][4] == "SE" or towerArray[towerIt][4] == "SW" then
  1387.         sectionLength = (math.abs(towerArray[towerIt+1][3] - towerArray[towerIt][3]) - 14)
  1388.     end
  1389.     if towerArray[towerIt][4] == "E" or towerArray[towerIt][4] == "W" then
  1390.         sectionLength = (math.abs(towerArray[towerIt+1][1] - towerArray[towerIt][1]) - 14)
  1391.     end
  1392.  
  1393.     -- Calculate incline
  1394.     sectionIncline = towerArray[towerIt+1][2] - towerArray[towerIt][2]
  1395.     -- Place straight wall section
  1396.     if towerArray[towerIt][4] =="N" or towerArray[towerIt][4] == "E" or towerArray[towerIt][4] == "S" or towerArray[towerIt][4] == "W" then
  1397.         for sectionIt=299, sectionLength do
  1398.             if multipleOf(sectionIt, sectionLength, sectionIncline) then
  1399.                 straightSlabs(sectionIncline)
  1400.                 if sectionIncline < 0 then
  1401.                     moveDown()
  1402.                 end
  1403.                 if sectionIncline > 0 then
  1404.                     moveUp()
  1405.                 end
  1406.             end
  1407.             place("stoneBrick")
  1408.             straightEscapeHatch(sectionLength, sectionIt)
  1409.             wallAccentTorch(sectionIt)
  1410.             digHeight = 0
  1411.             while robot.detect() == false or digHeight<21 or robot.detectDown() == false do
  1412.                 moveDown()
  1413.                 digHeight = digHeight + 1
  1414.                 if digHeight == 1 then place("stoneBrick") end
  1415.             end
  1416.             for i=1, digHeight do
  1417.                 moveUp()
  1418.                 if i == digHeight - 20 then
  1419.                     placeDown("stoneBrick")
  1420.                     moveBack()
  1421.                     placeDown("plank")
  1422.                 end
  1423.                 if (i == digHeight - 20 or i == digHeight - 19 or i == digHeight - 18) and sectionIt == 1 then
  1424.                     robot.turnLeft()
  1425.                     dig()
  1426.                     robot.turnRight()
  1427.                 end
  1428.                 if (i == digHeight - 20 or i == digHeight - 19 or i == digHeight - 18) and sectionIt == sectionLength then
  1429.                     robot.turnRight()
  1430.                     dig()
  1431.                     robot.turnLeft()
  1432.                 end
  1433.                 if i == digHeight - 4 then
  1434.                     externalTorch(sectionIt)
  1435.                 end
  1436.                 if i == 4 and i < digHeight - 20 then
  1437.                     externalTorchLow(sectionIt)
  1438.                 end
  1439.                 if i == 4 and i >= digHeight - 20 then
  1440.                     externalTorch(sectionIt)
  1441.                 end
  1442.                 if i < digHeight - 20 then
  1443.                     placeDown("stoneBrick")
  1444.                 elseif i == digHeight then
  1445.                     placeDown("stoneBrick")
  1446.                 else
  1447.                     place("stoneBrick")
  1448.                 end
  1449.                 if i == digHeight-17 then
  1450.                     internalTorch(sectionIt)
  1451.                 end
  1452.             end
  1453.             moveBack()
  1454.             moveBack()
  1455.             robot.turnAround()
  1456.             place("stoneBrick")
  1457.             wallAccentTorch(sectionIt)
  1458.             digHeight = 0
  1459.             while robot.detect() == false or digHeight<21 or robot.detectDown() == false do
  1460.                 moveDown()
  1461.                 digHeight = digHeight + 1
  1462.                 if digHeight == 1 then place("stoneBrick") end
  1463.             end
  1464.             for i=1, digHeight do
  1465.                 moveUp()
  1466.                 if i == digHeight - 20 then
  1467.                     placeDown("stoneBrick")
  1468.                     moveBack()
  1469.                     placeDown("plank")
  1470.                 end
  1471.                 if (i == digHeight - 20 or i == digHeight - 19 or i == digHeight - 18) and sectionIt == 1 then
  1472.                     robot.turnRight()
  1473.                     dig()
  1474.                     robot.turnLeft()
  1475.                 end
  1476.                 if (i == digHeight - 20 or i == digHeight - 19 or i == digHeight - 18) and sectionIt == sectionLength then
  1477.                     robot.turnLeft()
  1478.                     dig()
  1479.                     robot.turnRight()
  1480.                 end
  1481.                 if i == digHeight - 4 then
  1482.                     externalTorch(sectionIt)
  1483.                 end
  1484.                 if i == 4 and i < digHeight - 20 then
  1485.                     externalTorchLow(sectionIt)
  1486.                 end
  1487.                 if i == 4 and i >= digHeight - 20 then
  1488.                     externalTorch(sectionIt)
  1489.                 end
  1490.                 if i < digHeight - 20 then
  1491.                     placeDown("stoneBrick")
  1492.                 elseif i == digHeight then
  1493.                     placeDown("stoneBrick")
  1494.                 else
  1495.                     place("stoneBrick")
  1496.                 end
  1497.                 if i == digHeight-10 then
  1498.                     straightLogs(sectionIt)
  1499.                 end
  1500.                 if i == digHeight-17 then
  1501.                     internalTorch(sectionIt)
  1502.                 end
  1503.             end
  1504.             if sectionIt < sectionLength then
  1505.                 robot.turnLeft()
  1506.                 move()
  1507.                 robot.turnLeft()
  1508.                 move()
  1509.                 move()
  1510.             else
  1511.                 robot.turnLeft()
  1512.                 for i=1, 6 do move() end
  1513.                 robot.turnAround()
  1514.             end
  1515.         end
  1516.         -- return to south side for next tower sequence
  1517.         if towerArray[towerIt][4] == "N" then
  1518.             relocate("S","S")
  1519.         end
  1520.         if towerArray[towerIt][4] == "E" then
  1521.             relocate("W","S")
  1522.         end
  1523.         if towerArray[towerIt][4] == "S" then
  1524.             relocate("N","S")
  1525.         end
  1526.         if towerArray[towerIt][4] == "W" then
  1527.             relocate("E","S")
  1528.         end
  1529.     end
  1530.     -- Place diagonal wall section
  1531.     if towerArray[towerIt][4] =="NE" or towerArray[towerIt][4] == "SE" or towerArray[towerIt][4] == "SW" or towerArray[towerIt][4] == "NW" then
  1532.         -- do weird pre jut
  1533.         robot.turnRight()
  1534.         move()
  1535.         robot.turnLeft()
  1536.         move()
  1537.         robot.turnRight()
  1538.         place("stoneBrick")
  1539.         digHeight = 0
  1540.             while robot.detect() == false or robot.detectDown() == false or digHeight<21 do
  1541.                 moveDown()
  1542.                 digHeight = digHeight + 1
  1543.                 if digHeight == 1 then place("stoneBrick") end
  1544.             end
  1545.             for i=1, digHeight do
  1546.                 moveUp()
  1547.                 placeDown("stoneBrick")
  1548.                 if (i == digHeight - 20 or i == digHeight - 19 or i == digHeight - 18) then
  1549.                     robot.turnAround()
  1550.                     dig()
  1551.                     robot.turnAround()
  1552.                 end
  1553.             end
  1554.         robot.turnRight()
  1555.         move()
  1556.         robot.turnLeft()
  1557.         move()
  1558.         place("stoneBrick")
  1559.         digHeight = 0
  1560.         while robot.detect() == false or robot.detectDown() == false or digHeight<21 do
  1561.             moveDown()
  1562.             digHeight = digHeight + 1
  1563.             if digHeight == 1 then place("stoneBrick") end
  1564.         end
  1565.         for i=1, digHeight do
  1566.             moveUp()
  1567.             if i == digHeight - 20 then
  1568.                 placeDown("stoneBrick")
  1569.                 moveBack()
  1570.                 placeDown("plank")
  1571.                 moveBack()
  1572.                 placeDown("plank")
  1573.                 for i=1, 18 do
  1574.                     moveUp()
  1575.                 end
  1576.                 for i=1, 18 do
  1577.                     moveDown()
  1578.                 end
  1579.                 move()
  1580.             end
  1581.             if (i == digHeight - 20 or i == digHeight - 19 or i == digHeight - 18) then
  1582.                     robot.turnAround()
  1583.                     move()
  1584.                     dig()
  1585.                     robot.turnAround()
  1586.                     move()
  1587.             end
  1588.             if i < digHeight - 20 then
  1589.                 placeDown("stoneBrick")
  1590.             elseif i == digHeight then
  1591.                 placeDown("stoneBrick")
  1592.             else
  1593.                 place("stoneBrick")
  1594.             end
  1595.         end
  1596.         moveBack()
  1597.         placeDown("stoneBrick")
  1598.         robot.turnRight()
  1599.         move()
  1600.         robot.turnLeft()
  1601.         for i=1, 3 do move() end
  1602.         place("stoneBrick")
  1603.         moveUp()
  1604.         place("stoneBrick")
  1605.         moveDown()
  1606.         placeUp("torch")
  1607.         digHeight = 0
  1608.         while robot.detect() == false or robot.detectDown() == false or digHeight<21 do
  1609.             moveDown()
  1610.             digHeight = digHeight + 1
  1611.             if digHeight == 1 then place("stoneBrick") end
  1612.         end
  1613.         for i=1, digHeight do
  1614.             moveUp()
  1615.             if i == digHeight - 20 then
  1616.                 placeDown("stoneBrick")
  1617.                 moveBack()
  1618.                 placeDown("plank")
  1619.                 moveBack()
  1620.                 placeDown("plank")
  1621.                 moveBack()
  1622.                 placeDown("plank")
  1623.                 for i=1, 18 do
  1624.                     moveUp()
  1625.                     if robot.detect() then
  1626.                         dig()
  1627.                     end
  1628.                 end
  1629.                 robot.turnAround()
  1630.                 for ix=1, 18 do
  1631.                     if robot.detect() then
  1632.                         dig()
  1633.                     end
  1634.                     moveDown()
  1635.                     if (ix == 18 or ix == 17 or ix == 16) then
  1636.                         move()
  1637.                         dig()
  1638.                         moveBack()
  1639.                     end
  1640.                 end
  1641.                 move()
  1642.                 placeDown("plank")
  1643.                 robot.turnAround()
  1644.                 for i=1, 3 do move() end
  1645.             end
  1646.             if i == digHeight - 4 then
  1647.                 move()
  1648.                 if robot.detect() == false then
  1649.                     move()
  1650.                     placeDown("torch")
  1651.                     moveBack()
  1652.                 end
  1653.                 moveBack()
  1654.             end
  1655.             if i == 4 and i < digHeight - 20 then
  1656.                 if robot.detect() == false then
  1657.                     move()
  1658.                     placeDown("torch")
  1659.                     moveBack()
  1660.                 end
  1661.             end
  1662.             if i == 4 and i >= digHeight - 20 then
  1663.                 move()
  1664.                 if robot.detect() == false then
  1665.                     move()
  1666.                     placeDown("torch")
  1667.                     moveBack()
  1668.                 end
  1669.                 moveBack()
  1670.             end
  1671.             if i < digHeight - 20 then
  1672.                 placeDown("stoneBrick")
  1673.             elseif i == digHeight then
  1674.                 placeDown("stoneBrick")
  1675.             else
  1676.                 place("stoneBrick")
  1677.             end
  1678.             if i == digHeight-17 then
  1679.                 placeDown("torch")
  1680.             end
  1681.         end
  1682.         for i=1, 3 do
  1683.             moveBack()
  1684.             placeDown("stoneBrick")
  1685.         end
  1686.         robot.turnRight()
  1687.         move()
  1688.         robot.turnLeft()
  1689.         for i=1, 5 do
  1690.             move()
  1691.         end
  1692.         place("stoneBrick")
  1693.         moveUp()
  1694.         place("stoneBrick")
  1695.         moveDown()
  1696.         digHeight = 0
  1697.         while robot.detect() == false or robot.detectDown() == false or digHeight<21 do
  1698.             moveDown()
  1699.             digHeight = digHeight + 1
  1700.             if digHeight == 1 then place("stoneBrick") end
  1701.         end
  1702.         for i=1, digHeight do
  1703.             moveUp()
  1704.             if i == digHeight - 20 then
  1705.                 placeDown("stoneBrick")
  1706.                 moveBack()
  1707.                 placeDown("plank")
  1708.                 moveBack()
  1709.                 placeDown("plank")
  1710.                 moveBack()
  1711.                 placeDown("plank")
  1712.                 for i=1, 18 do
  1713.                     moveUp()
  1714.                     if robot.detect() then
  1715.                         dig()
  1716.                     end
  1717.                 end
  1718.                 robot.turnAround()
  1719.                 for i=1, 18 do
  1720.                     if robot.detect() then
  1721.                         dig()
  1722.                     end
  1723.                     moveDown()
  1724.                 end
  1725.                 move()
  1726.                 placeDown("plank")
  1727.                 robot.turnAround()
  1728.                 for i=1, 3 do move() end
  1729.             end
  1730.             if i < digHeight - 20 then
  1731.                 placeDown("stoneBrick")
  1732.             elseif i == digHeight then
  1733.                 placeDown("stoneBrick")
  1734.             else
  1735.                 place("stoneBrick")
  1736.             end
  1737.         end
  1738.         for i=1, 3 do
  1739.             moveBack()
  1740.             placeDown("stoneBrick")
  1741.         end
  1742.         moveBack()
  1743.         moveBack()
  1744.         robot.turnAround()
  1745.         digHeight = 0
  1746.         while robot.detectDown() == false or digHeight<21 or testLeft() == false do
  1747.             moveDown()
  1748.             digHeight = digHeight + 1
  1749.         end
  1750.         for i=1, digHeight do
  1751.             moveUp()
  1752.             if i == digHeight - 20 then
  1753.                 placeDown("stoneBrick")
  1754.                 moveBack()
  1755.                 placeDown("plank")
  1756.             end
  1757.             if i < digHeight - 20 then
  1758.                 placeDown("stoneBrick")
  1759.             elseif i == digHeight then
  1760.                 placeDown("stoneBrick")
  1761.             else
  1762.                 place("stoneBrick")
  1763.             end
  1764.         end
  1765.         robot.turnLeft()
  1766.         move()
  1767.         robot.turnLeft()
  1768.         for i=1, 6 do
  1769.             move()
  1770.         end
  1771.         -- end weird pre jut
  1772.         -- do diagonal wall
  1773.         for sectionIt=1, sectionLength do
  1774.             if multipleOf(sectionIt, sectionLength, sectionIncline) then
  1775.                 diagonalSlabs(sectionIncline)
  1776.                 if sectionIncline < 0 then
  1777.                     moveDown()
  1778.                 end
  1779.                 if sectionIncline > 0 then
  1780.                     moveUp()
  1781.                 end
  1782.             end
  1783.             place("stoneBrick")
  1784.             diagonalEscapeHatch(sectionLength, sectionIt)
  1785.             diagWallAccentTorch(sectionIt)
  1786.             digHeight = 0
  1787.             while robot.detect() == false or robot.detectDown() == false or digHeight<21 do
  1788.                 moveDown()
  1789.                 digHeight = digHeight + 1
  1790.                 if digHeight == 1 then place("stoneBrick") end
  1791.             end
  1792.             for i=1, digHeight do
  1793.                 moveUp()
  1794.                 if i == digHeight - 20 then
  1795.                     placeDown("stoneBrick")
  1796.                     moveBack()
  1797.                     placeDown("plank")
  1798.                     moveBack()
  1799.                     placeDown("plank")
  1800.                     moveBack()
  1801.                     placeDown("plank")
  1802.                     for i=1, 18 do
  1803.                         moveUp()
  1804.                         if robot.detect() then
  1805.                             dig()
  1806.                         end
  1807.                     end
  1808.                     robot.turnAround()
  1809.                     for i=1, 18 do
  1810.                         if robot.detect() then
  1811.                             dig()
  1812.                         end
  1813.                         moveDown()
  1814.                     end
  1815.                     move()
  1816.                     placeDown("plank")
  1817.                     robot.turnAround()
  1818.                     for i=1, 3 do move() end
  1819.                 end
  1820.                 if i == digHeight - 4 then
  1821.                     diagExternalTorch(sectionIt)
  1822.                 end
  1823.                 if i == 4 and i < digHeight - 20 then
  1824.                     diagExternalTorchLow(sectionIt)
  1825.                 end
  1826.                 if i == 4 and i >= digHeight - 20 then
  1827.                     diagExternalTorch(sectionIt)
  1828.                 end
  1829.                 if i < digHeight - 20 then
  1830.                     placeDown("stoneBrick")
  1831.                 elseif i == digHeight then
  1832.                     placeDown("stoneBrick")
  1833.                 else
  1834.                     place("stoneBrick")
  1835.                 end
  1836.                 if i == digHeight-17 then
  1837.                     diagInternalTorch(sectionIt)
  1838.                 end
  1839.             end
  1840.             for i=1, 3 do
  1841.                 moveBack()
  1842.                 placeDown("stoneBrick")
  1843.             end
  1844.             moveBack()
  1845.             moveBack()
  1846.             robot.turnAround()
  1847.             place("stoneBrick")
  1848.             diagWallAccentTorch(sectionIt)
  1849.             digHeight = 0
  1850.             while robot.detect() == false or robot.detectDown() == false or digHeight<21 do
  1851.                 moveDown()
  1852.                 digHeight = digHeight + 1
  1853.                 if digHeight == 1 then place("stoneBrick") end
  1854.             end
  1855.             for i=1, digHeight do
  1856.                 moveUp()
  1857.                 if i == digHeight - 20 then
  1858.                     placeDown("stoneBrick")
  1859.                     moveBack()
  1860.                     placeDown("plank")
  1861.                 end
  1862.                 if i == digHeight - 4 then
  1863.                     diagExternalTorch(sectionIt)
  1864.                 end
  1865.                 if i == 4 and i < digHeight - 20 then
  1866.                     diagExternalTorchLow(sectionIt)
  1867.                 end
  1868.                 if i == 4 and i >= digHeight - 20 then
  1869.                     diagExternalTorch(sectionIt)
  1870.                 end
  1871.                 if i < digHeight - 20 then
  1872.                     placeDown("stoneBrick")
  1873.                 elseif i == digHeight then
  1874.                     placeDown("stoneBrick")
  1875.                 else
  1876.                     place("stoneBrick")
  1877.                 end
  1878.                 if i == digHeight-10 then
  1879.                     diagonalLogs(sectionIt)
  1880.                 end
  1881.                 if i == digHeight-17 then
  1882.                     diagInternalTorch(sectionIt)
  1883.                 end
  1884.             end
  1885.             if sectionIt < sectionLength then
  1886.                 robot.turnLeft()
  1887.                 move()
  1888.                 robot.turnLeft()
  1889.                 for i=1, 6 do
  1890.                     move()
  1891.                 end
  1892.             end
  1893.         end
  1894.         -- do weird post jut
  1895.         robot.turnAround()
  1896.         for i=1, 3 do
  1897.             move()
  1898.         end
  1899.         robot.turnRight()
  1900.         for i=1, 4 do
  1901.             move()
  1902.         end
  1903.         robot.turnRight()
  1904.         place("stoneBrick")
  1905.         digHeight = 0
  1906.             while robot.detect() == false or robot.detectDown() == false or digHeight<21 do
  1907.                 moveDown()
  1908.                 digHeight = digHeight + 1
  1909.                 if digHeight == 1 then place("stoneBrick") end
  1910.             end
  1911.             for i=1, digHeight do
  1912.                 moveUp()
  1913.                 placeDown("stoneBrick")
  1914.                 if (i == digHeight - 20 or i == digHeight - 19 or i == digHeight - 18) then
  1915.                     robot.turnAround()
  1916.                     dig()
  1917.                     robot.turnAround()
  1918.                 end
  1919.             end
  1920.         robot.turnRight()
  1921.         move()
  1922.         robot.turnLeft()
  1923.         move()
  1924.         place("stoneBrick")
  1925.         digHeight = 0
  1926.         while robot.detect() == false or robot.detectDown() == false or digHeight<21 do
  1927.             moveDown()
  1928.             digHeight = digHeight + 1
  1929.             if digHeight == 1 then place("stoneBrick") end
  1930.         end
  1931.         for i=1, digHeight do
  1932.             moveUp()
  1933.             if i == digHeight - 20 then
  1934.                 placeDown("stoneBrick")
  1935.                 moveBack()
  1936.                 placeDown("plank")
  1937.                 moveBack()
  1938.                 placeDown("plank")
  1939.                 for i=1, 18 do
  1940.                     moveUp()
  1941.                 end
  1942.                 for i=1, 18 do
  1943.                     moveDown()
  1944.                 end
  1945.                 move()
  1946.             end
  1947.             if (i == digHeight - 20 or i == digHeight - 19 or i == digHeight - 18) then
  1948.                     robot.turnAround()
  1949.                     move()
  1950.                     dig()
  1951.                     robot.turnAround()
  1952.                     move()
  1953.             end
  1954.             if i < digHeight - 20 then
  1955.                 placeDown("stoneBrick")
  1956.             elseif i == digHeight then
  1957.                 placeDown("stoneBrick")
  1958.             else
  1959.                 place("stoneBrick")
  1960.             end
  1961.         end
  1962.         moveBack()
  1963.         placeDown("stoneBrick")
  1964.         robot.turnRight()
  1965.         move()
  1966.         robot.turnLeft()
  1967.         for i=1, 3 do move() end
  1968.         place("stoneBrick")
  1969.         moveUp()
  1970.         place("stoneBrick")
  1971.         moveDown()
  1972.         placeUp("torch")
  1973.         digHeight = 0
  1974.         while robot.detect() == false or robot.detectDown() == false or digHeight<21 do
  1975.             moveDown()
  1976.             digHeight = digHeight + 1
  1977.             if digHeight == 1 then place("stoneBrick") end
  1978.         end
  1979.         for i=1, digHeight do
  1980.             moveUp()
  1981.             if i == digHeight - 20 then
  1982.                 placeDown("stoneBrick")
  1983.                 moveBack()
  1984.                 placeDown("plank")
  1985.                 moveBack()
  1986.                 placeDown("plank")
  1987.                 moveBack()
  1988.                 placeDown("plank")
  1989.                 for i=1, 18 do
  1990.                     moveUp()
  1991.                     if robot.detect() then
  1992.                         dig()
  1993.                     end
  1994.                 end
  1995.                 robot.turnAround()
  1996.                 for ix=1, 18 do
  1997.                     if robot.detect() then
  1998.                         dig()
  1999.                     end
  2000.                     moveDown()
  2001.                     if (ix == 18 or ix == 17 or ix == 16) then
  2002.                         move()
  2003.                         dig()
  2004.                         moveBack()
  2005.                     end
  2006.                 end
  2007.                 move()
  2008.                 placeDown("plank")
  2009.                 robot.turnAround()
  2010.                 for i=1, 3 do move() end
  2011.             end
  2012.             if i == digHeight - 4 then
  2013.                 move()
  2014.                 if robot.detect() == false then
  2015.                     move()
  2016.                     placeDown("torch")
  2017.                     moveBack()
  2018.                 end
  2019.                 moveBack()
  2020.             end
  2021.             if i == 4 and i < digHeight - 20 then
  2022.                 if robot.detect() == false then
  2023.                     move()
  2024.                     placeDown("torch")
  2025.                     moveBack()
  2026.                 end
  2027.             end
  2028.             if i == 4 and i >= digHeight - 20 then
  2029.                 move()
  2030.                 if robot.detect() == false then
  2031.                     move()
  2032.                     placeDown("torch")
  2033.                     moveBack()
  2034.                 end
  2035.                 moveBack()
  2036.             end
  2037.             if i < digHeight - 20 then
  2038.                 placeDown("stoneBrick")
  2039.             elseif i == digHeight then
  2040.                 placeDown("stoneBrick")
  2041.             else
  2042.                 place("stoneBrick")
  2043.             end
  2044.             if i == digHeight-17 then
  2045.                 placeDown("torch")
  2046.             end
  2047.         end
  2048.         for i=1, 3 do
  2049.             moveBack()
  2050.             placeDown("stoneBrick")
  2051.         end
  2052.         robot.turnRight()
  2053.         move()
  2054.         robot.turnLeft()
  2055.         for i=1, 5 do
  2056.             move()
  2057.         end
  2058.         place("stoneBrick")
  2059.         moveUp()
  2060.         place("stoneBrick")
  2061.         moveDown()
  2062.         digHeight = 0
  2063.         while robot.detect() == false or robot.detectDown() == false or digHeight<21 do
  2064.             moveDown()
  2065.             digHeight = digHeight + 1
  2066.             if digHeight == 1 then place("stoneBrick") end
  2067.         end
  2068.         for i=1, digHeight do
  2069.             moveUp()
  2070.             if i == digHeight - 20 then
  2071.                 placeDown("stoneBrick")
  2072.                 moveBack()
  2073.                 placeDown("plank")
  2074.                 moveBack()
  2075.                 placeDown("plank")
  2076.                 moveBack()
  2077.                 placeDown("plank")
  2078.                 for i=1, 18 do
  2079.                     moveUp()
  2080.                     if robot.detect() then
  2081.                         dig()
  2082.                     end
  2083.                 end
  2084.                 robot.turnAround()
  2085.                 for i=1, 18 do
  2086.                     if robot.detect() then
  2087.                         dig()
  2088.                     end
  2089.                     moveDown()
  2090.                 end
  2091.                 move()
  2092.                 placeDown("plank")
  2093.                 robot.turnAround()
  2094.                 for i=1, 3 do move() end
  2095.             end
  2096.             if i < digHeight - 20 then
  2097.                 placeDown("stoneBrick")
  2098.             elseif i == digHeight then
  2099.                 placeDown("stoneBrick")
  2100.             else
  2101.                 place("stoneBrick")
  2102.             end
  2103.         end
  2104.         for i=1, 3 do
  2105.             moveBack()
  2106.             placeDown("stoneBrick")
  2107.         end
  2108.         moveBack()
  2109.         moveBack()
  2110.         robot.turnAround()
  2111.         digHeight = 0
  2112.         while robot.detectDown() == false or digHeight<21 or testLeft() == false do
  2113.             moveDown()
  2114.             digHeight = digHeight + 1
  2115.         end
  2116.         for i=1, digHeight do
  2117.             moveUp()
  2118.             if i == digHeight - 20 then
  2119.                 placeDown("stoneBrick")
  2120.                 moveBack()
  2121.                 placeDown("plank")
  2122.             end
  2123.             if i < digHeight - 20 then
  2124.                 placeDown("stoneBrick")
  2125.             elseif i == digHeight then
  2126.                 placeDown("stoneBrick")
  2127.             else
  2128.                 place("stoneBrick")
  2129.             end
  2130.         end
  2131.         -- end weird post jut
  2132.         -- return to south side for next tower sequence
  2133.         robot.turnRight()
  2134.         for i=1, 5 do
  2135.             move()
  2136.         end
  2137.         robot.turnLeft()
  2138.         for i=1, 4 do
  2139.             move()
  2140.         end
  2141.         robot.turnLeft() -- we back on side facing out
  2142.         if towerArray[towerIt][4] == "NE" then
  2143.             relocate("W","S")
  2144.         end
  2145.         if towerArray[towerIt][4] == "SE" then
  2146.             relocate("N","S")
  2147.         end
  2148.         if towerArray[towerIt][4] == "SW" then
  2149.             relocate("E","S")
  2150.         end
  2151.         if towerArray[towerIt][4] == "NW" then
  2152.             relocate("S","S")
  2153.         end
  2154.     end
  2155.     while robot.detectDown() == false do moveDown() end
  2156.     robot.turnAround()
  2157. end
  2158. computer.shutdown()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement