Advertisement
Blackhome

FluidProofer

Jan 7th, 2025 (edited)
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.73 KB | Gaming | 0 0
  1. --[[
  2.     status:         1: Digs up area,
  3.                     2: Digs up area + side walls
  4.                     3: Waterproof + side walls
  5.                     4: Digs up area + all walls
  6.                     5: Waterproof + all walls
  7.                 else:  input settings
  8.  
  9.     dF:             length in forward direction
  10.     dR:             length in right direction
  11.     dU:             hight of area
  12. ]]
  13.  
  14. local status, dF, dR, dU = ...
  15. local mode = 0
  16. if status then
  17.     mode = tonumber(status)
  18. end
  19.  
  20. local move = require("move1")
  21. local inspect = require("inspect1")
  22. local bWaterproof = false
  23. local bFull = false
  24.  
  25.  
  26. information1 = [[
  27. This program digs up a specified area.
  28. You can select between five different modi:
  29.     1. Dig up area
  30.     2. Dig up area + build side walls
  31.     3. Like 2 + waterproof
  32.     4. Dig up area + all walls
  33.     5. Like 4 + waterproof
  34.  
  35. Type something to continue]]
  36.  
  37. information2 = [[
  38. You can choose the mode in the first argument when starting the programm or by adjusting the settings.
  39.  
  40. The second to fourth argument define the size of the area:
  41.     second: forward length
  42.     third:  right width (side)
  43.     fourth: height
  44.  
  45. Type something to continue]]
  46.  
  47. building_material = {  
  48.                         "minecraft:cobblestone", "minecraft:cobbled_deepslate",
  49.                         "minecraft:tuff", "minecraft:andesite",
  50.                         "minecraft:diorite", "minecraft:granite"
  51.                     }
  52.  
  53. waterlogged_blocks = {
  54.     "minecraft:activator_rail", "1_dripleaf",
  55.     "1_amethyst_bud", "amethyst_cluster",
  56.     "minecraft:soul_campfire", "minecraft:campfire",
  57.     "1_candle", "minecraft:calibrated_sculk_sensor",
  58.     "minecraft:chain", "minecraft:chest",
  59.     "minecraft:conduit", "1_grate",
  60.     "minecraft:dead_horn_coral_fan", "minecraft:horn_coral_fan",
  61.     "minecraft:dead_horn_coral", "minecraft:horn_coral",
  62.     "minecraft:dead_fire_coral_fan", "minecraft:fire_coral_fan",
  63.     "minecraft:dead_fire_coral", "minecraft:fire_coral",
  64.  
  65.     "minecraft:dead_bubble_coral_fan", "minecraft:bubble_coral_fan",
  66.     "minecraft:dead_bubble_coral", "minecraft:bubble_coral",
  67.     "minecraft:dead_brain_coral_fan", "minecraft:brain_coral_fan",
  68.     "minecraft:dead_brain_coral", "minecraft:brain_coral",
  69.     "minecraft:dead_tube_coral_fan", "minecraft:brain_tube_fan",
  70.     "minecraft:dead_tube_coral", "minecraft:tube_coral",
  71.     "minecraft:decorated_pot", "minecraft:detector_rail",
  72.     "minecraft:ender_chest", "1_fence",
  73.     "1_pane", "minecraft:glow_lichen",
  74.     "minecraft:hanging_roots", "minecraft:heavy_core",
  75.  
  76.  
  77.     "minecraft:iron_bars", "minecraft:",
  78.     "minecraft:kelp", "minecraft:kelp_plant",
  79.     "minecraft:ladder", "minecraft:lantern",
  80.     "minecraft:soul_lantern", "1_leaves",
  81.     "minecraft:lightning_rod", "minecraft:mangrove_propagule",
  82.     "minecraft:mangrove_roots", "minecraft:pointed_dripstone",
  83.     "minecraft:powered_rail", "minecraft:rail",
  84.     "minecraft:scaffolding", "minecraft:sculk_vein",
  85.     "minecraft:sculk_shrieker", "minecraft:sculk_sensor",
  86.     "minecraft:sea_pickle", "minecraft:seagrass",
  87.  
  88.     "1_sign", "1_slab",
  89.     "1_stairs", "minecraft:tall_seagrass",
  90.     "1_trap", "1_wall",
  91. }
  92.                    
  93. falling_blocks = {
  94.     "minecraft:gravel", "minecraft:red_sand",
  95.     "minecraft:sand", "minecraft:suspicious_sand",
  96.     "1_anvil", "1_concrete_powder",
  97.     "minecraft:dragon_egg", "minecraft:pointed_dripstone",
  98.     "minecraft:scaffolding", "minecraft:",
  99.     "minecraft:suspicious_gravel"
  100. }
  101.  
  102. local function getSettings()
  103.     local y_n_toBoolean = { ["y"] = true, ["n"] = false }
  104.     local numDecision = 1
  105.  
  106.     print("Type 1 to run the default code")
  107.     print("Type 2 to adjust the settings")
  108.     print("Type 3 to exit")
  109.     print("Type 4 for further information")
  110.     numDecision = tonumber(io.read())
  111.     print("")
  112.  
  113.     if numDecision == 4 then
  114.         print(information1)
  115.         io.read()
  116.         print(information2)
  117.         io.read()
  118.         print("Type 1 to run the default code")
  119.         print("Type 2 to adjust the settings")
  120.         print("Type 3 to exit")
  121.         numDecision = tonumber(io.read())
  122.     end
  123.  
  124.     if ((numDecision >= 3) or (numDecision < 1)) then
  125.         return 0, nil, nil, nil
  126.     elseif numDecision == 1 then
  127.         return 1, 50, 3, 3
  128.     else
  129.         print("")
  130.         print("Enter in which modus you want to dig up the area (1/2/3/4/5)")
  131.         local modus_A = tonumber(io.read())
  132.         print("")
  133.         print("Enter the length of the area")
  134.         local length_F = tonumber(io.read())
  135.         print("")
  136.         print("Enter the width of the area")
  137.         local width_R = tonumber(io.read())
  138.         print("")
  139.         print("Enter the height of the area")
  140.         local height_H = tonumber(io.read())
  141.  
  142.         return modus_A, length_F, width_R, height_H
  143.     end
  144. end
  145.  
  146. if mode == 0 then
  147.     mode, dF, dR, dU = getSettings()
  148. end
  149. if mode == 0 or mode > 5 then
  150.     print("Wrong input")
  151.     print("Exiting the programm")
  152.     return
  153. end
  154.  
  155. if mode == 3 then
  156.     mode = 2
  157.     bWaterproof = true
  158. end
  159. if mode == 5 then
  160.     mode = 4
  161.     bWaterproof = true
  162. end
  163.  
  164. local deltaForward = 50
  165. if dF then
  166.     deltaForward = tonumber(dF)
  167. end
  168.  
  169. local deltaRight = 3
  170. if dR then
  171.     deltaRight = tonumber(dR)
  172. end
  173.  
  174. local deltaUp = 3
  175. if dU then
  176.     deltaUp = tonumber(dU)
  177. end
  178.  
  179. print("Arguments:")
  180. print(mode, deltaForward, deltaRight, deltaUp)
  181. print("Waterproof:  "..tostring(bWaterproof))
  182.  
  183. -- forward, right, up
  184. turtlePos = {0, 0, 0}
  185. turtleLastPos = {turtlePos[1], turtlePos[2], turtlePos[3]}
  186. -- {1, 0} = forward,  {0, 1} = right,  {-1, 0} = back,  {0, -1} = left
  187. turtleVec = {1, 0}
  188. turtleLastVec = {turtleVec[1], turtleVec[2]}
  189.  
  190. local function varInArr(var, arr)
  191.     for i = 1, #arr, 1 do
  192.         if var == arr[i] then
  193.             return true
  194.         end
  195.     end
  196.     return false
  197. end
  198.  
  199. local function loc_MoveForward(t_pos, t_direct)
  200.     move.Forward()
  201.     t_pos[1] = t_pos[1] + t_direct[1]
  202.     t_pos[2] = t_pos[2] + t_direct[2]
  203. end
  204. local function loc_MoveUp(t_pos, t_direct)
  205.     move.Up()
  206.     t_pos[3] = t_pos[3] + 1
  207. end
  208. local function loc_MoveDown(t_pos, t_direct)
  209.     move.Down()
  210.     t_pos[3] = t_pos[3] - 1
  211. end
  212. local function loc_TurnLeft(t_direct)
  213.     turtle.turnLeft()
  214.     local buffer = t_direct[1]
  215.     t_direct[1] = t_direct[2]
  216.     t_direct[2] = -buffer
  217. end
  218. local function loc_TurnRight(t_direct)
  219.     turtle.turnRight()
  220.     local buffer = t_direct[1]
  221.     t_direct[1] = -t_direct[2]
  222.     t_direct[2] = buffer
  223. end
  224.  
  225. local function selectItemFromList(itemList)
  226.     local itemA = turtle.getItemDetail()
  227.     if itemA then
  228.         if varInArr(itemA.name, itemList) then
  229.             return true
  230.         end
  231.     end
  232.  
  233.     for i=1, 16, 1 do
  234.         if turtle.getItemCount(i) > 0 then
  235.             turtle.select(i)
  236.             local itemB = turtle.getItemDetail()
  237.             if itemB then
  238.                 if varInArr(itemB.name, itemList) then
  239.                     return true
  240.                 end
  241.             end
  242.         end
  243.     end
  244.     return false
  245. end
  246.  
  247. local function tryOffloadItems()
  248.     local bChest = inspect.Forward({"minecraft:chest"})
  249.     if bFull then
  250.         for i=16, 1, -1 do
  251.             if turtle.getItemCount(i) == 0 then
  252.                 bFull = false
  253.             end
  254.         end
  255.     end
  256.     if not bChest then
  257.         if bFull then
  258.             print("Pls take out items from inventory or place a chest")
  259.             io.read()
  260.             tryOffloadItems()
  261.         end
  262.         return
  263.     end
  264.  
  265.     local arrStackSize = {}
  266.     for i=1, 16, 1 do
  267.         local numItems = turtle.getItemCount(i)
  268.         if numItems > 0 then
  269.             turtle.select(i)
  270.             local itemDetail = turtle.getItemDetail()
  271.  
  272.             if itemDetail then
  273.                 if not varInArr(itemDetail.name, building_material) then
  274.                     if not turtle.drop() then
  275.                         if bFull then
  276.                             print("Pls take out items from inventory or from chest")
  277.                             io.read()
  278.                             tryOffloadItems()
  279.                         end
  280.                     else
  281.                         bFull = false
  282.                     end
  283.                 else
  284.                     table.insert(arrStackSize, {slot = i, stackSize = numItems})
  285.                 end
  286.             end
  287.         end
  288.     end
  289.     table.sort(arrStackSize, function(a, b) return a.stackSize > b.stackSize end)
  290.  
  291.     for i=5, #arrStackSize, 1 do
  292.         local slotVar = arrStackSize[i].slot
  293.         turtle.select(slotVar)
  294.         if not turtle.drop() then
  295.             if bFull then
  296.                 print("Pls take out items from inventory or from chest")
  297.                 io.read()
  298.                 tryOffloadItems()
  299.             end
  300.         else
  301.             bFull = false
  302.         end
  303.     end
  304.  
  305. end
  306.  
  307. local function goToStart()
  308.     if not(((turtlePos[1] + turtlePos[2] + turtlePos[3]) == 0) and (turtleVec[1] == -1)) then
  309.         turtleLastPos = {turtlePos[1], turtlePos[2], turtlePos[3]}
  310.         turtleLastVec = {turtleVec[1], turtleVec[2]}
  311.     end
  312.  
  313.     while turtleVec[1] > -1 do
  314.         loc_TurnRight(turtleVec)
  315.     end
  316.     if (turtlePos[1] + turtlePos[2] + turtlePos[3]) > 0 then
  317.         while turtlePos[1] > 0 do
  318.             loc_MoveForward(turtlePos, turtleVec)
  319.         end
  320.         loc_TurnRight(turtleVec)
  321.         while turtlePos[2] > 0 do
  322.             loc_MoveForward(turtlePos, turtleVec)
  323.         end
  324.         loc_TurnLeft(turtleVec)
  325.         while turtlePos[3] > 0 do
  326.             loc_MoveDown(turtlePos, turtleVec)
  327.         end
  328.     end
  329.     tryOffloadItems()
  330. end
  331.  
  332. local function goToLastPosition()
  333.     while turtlePos[3] < turtleLastPos[3] do
  334.         loc_MoveUp(turtlePos, turtleVec)
  335.     end
  336.     loc_TurnLeft(turtleVec)
  337.     while turtlePos[2] < turtleLastPos[2] do
  338.         loc_MoveForward(turtlePos, turtleVec)
  339.     end
  340.     loc_TurnLeft(turtleVec)
  341.     while turtlePos[1] < turtleLastPos[1] do
  342.         loc_MoveForward(turtlePos, turtleVec)
  343.     end
  344.  
  345.     while not (turtleVec[1] == turtleLastVec[1] and turtleVec[2] == turtleLastVec[2]) do
  346.         loc_TurnLeft(turtleVec)
  347.     end
  348. end
  349.  
  350. local function fluidProofForward()
  351.     local bMovement_required = false
  352.     while true do
  353.         if selectItemFromList(building_material) then
  354.             break
  355.         else
  356.             bMovement_required = true
  357.             goToStart()
  358.             print("Please put in new building material")
  359.             io.read()
  360.         end
  361.     end
  362.     if bMovement_required then
  363.         print("Going back to work")
  364.         goToLastPosition()
  365.     end
  366.     if not (turtle.detect()) then
  367.         while not turtle.place() do
  368.             turtle.dig()
  369.         end
  370.     elseif inspect.Forward(falling_blocks) then
  371.         while not turtle.place() do
  372.             turtle.dig()
  373.         end
  374.     elseif inspect.Forward(waterlogged_blocks) then
  375.         while not turtle.place() do
  376.             turtle.dig()
  377.         end
  378.     end
  379. end
  380.  
  381. local function fluidProofUp()
  382.     local bMovement_required = false
  383.     while true do
  384.         if selectItemFromList(building_material) then
  385.             break
  386.         else
  387.             bMovement_required = true
  388.             goToStart()
  389.             print("Please put in new building material")
  390.             io.read()
  391.         end
  392.     end
  393.     if bMovement_required then
  394.         print("Going back to work")
  395.         goToLastPosition()
  396.     end
  397.     if not (turtle.detectUp()) then
  398.         while not turtle.placeUp() do
  399.             turtle.digUp()
  400.         end
  401.     elseif inspect.Up(falling_blocks) then
  402.         while not turtle.placeUp() do
  403.             turtle.digUp()
  404.         end
  405.     elseif inspect.Up(waterlogged_blocks) then
  406.         while not turtle.placeUp() do
  407.             turtle.digUp()
  408.         end
  409.     end
  410.    
  411. end
  412.  
  413. local function fluidProofDown()
  414.     local bMovement_required = false
  415.     while true do
  416.         if selectItemFromList(building_material) then
  417.             break
  418.         else
  419.             bMovement_required = true
  420.             goToStart()
  421.             print("Please put in new building material")
  422.             io.read()
  423.         end
  424.     end
  425.     if bMovement_required then
  426.         print("Going back to work")
  427.         goToLastPosition()
  428.     end
  429.     if not (turtle.detectDown()) then
  430.         while not turtle.placeDown() do
  431.             turtle.digDown()
  432.         end
  433.     elseif inspect.Down(falling_blocks) then
  434.         while not turtle.placeDown() do
  435.             turtle.digDown()
  436.         end
  437.     elseif inspect.Down(waterlogged_blocks) then
  438.         while not turtle.placeDown() do
  439.             turtle.digDown()
  440.         end
  441.     end
  442. end
  443.  
  444. -- checks if turtle has enough fuel and refuels if not
  445. local function checkAndRefuel()
  446.     local distance = turtlePos[1] + turtlePos[2] + turtlePos[3]
  447.     local multiplier = 1
  448.     if distance == 0 then
  449.         distance = turtleLastPos[1] + turtleLastPos[2] + turtleLastPos[3]
  450.         multiplier = 2
  451.     end
  452.     local fuelLevel = turtle.getFuelLevel()
  453.  
  454.     local fuelBuffer = 10
  455.  
  456.     if fuelLevel > multiplier * distance + fuelBuffer then
  457.         return
  458.     end
  459.     goToStart()
  460.     tryOffloadItems()
  461.     multiplier = 2
  462.  
  463.     print("Pls add fuel to turtle")
  464.  
  465.     while true do
  466.         io.read()
  467.         move.refuelProcess()
  468.         fuelLevel = turtle.getFuelLevel()
  469.         if fuelLevel > 2 * distance + fuelBuffer then
  470.             break
  471.         else
  472.             print("Not enough fuel was added, pls try again")
  473.         end
  474.     end
  475.     goToLastPosition()
  476.  
  477. end
  478.  
  479. --checks if turtle has an empty slot and unloads if not
  480. local function checkAndUnload()
  481.     for i=16, 1, -1 do
  482.         if turtle.getItemCount(i) == 0 then
  483.             bFull = false
  484.             return
  485.         end
  486.     end
  487.     bFull = true
  488.     goToStart()
  489.     tryOffloadItems()
  490.     checkAndRefuel()
  491.     goToLastPosition()
  492.  
  493. end
  494.  
  495. -- Digs up the given area
  496. function digArea(modus, lenForward, lenRight, lenUp)
  497.     local rowCnt = 1
  498.  
  499.     local bOutside = false
  500.     -- Go forward
  501.     for i=1, lenForward, 1 do
  502.         if modus == 1 then
  503.             if i % 2 == 1 then
  504.                 loc_TurnRight(turtleVec)
  505.             else
  506.                 loc_TurnLeft(turtleVec)
  507.             end
  508.         end
  509.         -- Go sideways
  510.         for j=1, lenRight, 1 do
  511.             -- Go up/down
  512.             for k=1, lenUp - 1, 1 do
  513.                 checkAndRefuel()
  514.                 checkAndUnload()
  515.  
  516.                 -- Odd rows (starting with 1) up, even rows down
  517.                 local condition_1 = (j == 1 and modus >= 2)
  518.                 local condition_2 = (j == lenRight and modus >= 2)
  519.                
  520.                 local condition_3 = (i == 1 and modus == 4)
  521.                 local condition_4 = (i == lenForward and modus == 4)
  522.  
  523.                 -- bottom or top of side wall: place block if there is none
  524.                 if (k == 1 and condition_1) then
  525.                     if i % 2 == 1 then
  526.                         loc_TurnLeft(turtleVec)
  527.                     else
  528.                         loc_TurnRight(turtleVec)
  529.                     end
  530.                     fluidProofForward()
  531.                 end
  532.                 if (k == 1 and condition_2) then
  533.                     fluidProofForward()
  534.                     if condition_3 then
  535.                         loc_TurnRight(turtleVec)
  536.                         fluidProofForward()
  537.                         loc_TurnLeft(turtleVec)
  538.                     end
  539.                 end
  540.                 -- place up/down block if k starts
  541.                 if (k == 1 and modus > 1) then
  542.                     if rowCnt % 2 == 1 then
  543.                         fluidProofDown()
  544.                     else
  545.                         fluidProofUp()
  546.                     end
  547.                     if condition_3 and (not(j == 1)) then
  548.                         loc_TurnRight(turtleVec)
  549.                         fluidProofForward()
  550.                         loc_TurnLeft(turtleVec)
  551.                     elseif condition_4 then
  552.                         if i % 2 == 1 then
  553.                             if j == 1 then
  554.                                 loc_TurnRight(turtleVec)
  555.                                 fluidProofForward()
  556.                                 loc_TurnLeft(turtleVec)
  557.                             else
  558.                                 loc_TurnLeft(turtleVec)
  559.                                 fluidProofForward()
  560.                                 loc_TurnRight(turtleVec)
  561.                             end
  562.                         else
  563.                             if j == 1 then
  564.                                 loc_TurnLeft(turtleVec)
  565.                                 fluidProofForward()
  566.                                 loc_TurnRight(turtleVec)
  567.                             else
  568.                                 loc_TurnRight(turtleVec)
  569.                                 fluidProofForward()
  570.                                 loc_TurnLeft(turtleVec)
  571.                             end
  572.                         end
  573.                     end
  574.                 end
  575.                 if rowCnt % 2 == 1 then
  576.                     loc_MoveUp(turtlePos, turtleVec)
  577.                 else
  578.                     loc_MoveDown(turtlePos, turtleVec)
  579.                 end
  580.  
  581.                 -- places block if on side
  582.                 if (condition_1 or condition_2) then
  583.                     fluidProofForward()
  584.                     if condition_3 and condition_1 then
  585.                         if k > 1 then
  586.                             loc_TurnLeft(turtleVec)
  587.                             fluidProofForward()
  588.                             loc_TurnRight(turtleVec)
  589.                         end
  590.                     end
  591.                     if condition_3 and condition_2 then
  592.                         loc_TurnRight(turtleVec)
  593.                         fluidProofForward()
  594.                         loc_TurnLeft(turtleVec)
  595.                     end
  596.                     if condition_4 and condition_1 then
  597.                         if i % 2 == 1 then
  598.                             loc_TurnRight(turtleVec)
  599.                             fluidProofForward()
  600.                             loc_TurnLeft(turtleVec)
  601.                         else
  602.                             loc_TurnLeft(turtleVec)
  603.                             fluidProofForward()
  604.                             loc_TurnRight(turtleVec)
  605.                         end
  606.                     end
  607.                     if condition_4 and condition_2 then
  608.                         if i % 2 == 1 then
  609.                             loc_TurnLeft(turtleVec)
  610.                             fluidProofForward()
  611.                             loc_TurnRight(turtleVec)
  612.                         else
  613.                             loc_TurnRight(turtleVec)
  614.                             fluidProofForward()
  615.                             loc_TurnLeft(turtleVec)
  616.                         end
  617.                     end
  618.                 elseif  condition_3 then
  619.                     loc_TurnRight(turtleVec)
  620.                     fluidProofForward()
  621.                     loc_TurnLeft(turtleVec)
  622.                 elseif condition_4 then
  623.                     if i % 2 == 1 then
  624.                         loc_TurnLeft(turtleVec)
  625.                         fluidProofForward()
  626.                         loc_TurnRight(turtleVec)
  627.                     else
  628.                         loc_TurnRight(turtleVec)
  629.                         fluidProofForward()
  630.                         loc_TurnLeft(turtleVec)
  631.                     end
  632.                 end
  633.  
  634.                 -- place up/down block if k starts
  635.                 if (k == lenUp - 1 and modus > 1) then
  636.                     if rowCnt % 2 == 1 then
  637.                         fluidProofUp()
  638.                     else
  639.                         fluidProofDown()
  640.                     end
  641.                 end
  642.                 -- turns back in right direction
  643.                 if (k == lenUp - 1 and condition_1) then
  644.                     loc_TurnLeft(turtleVec)
  645.                     loc_TurnLeft(turtleVec)
  646.                 end
  647.                
  648.             end
  649.             -- After odd planes (y-z plane) turn left, after even ones right
  650.             if j == lenRight then
  651.                 if i % 2 == 1 then
  652.                     loc_TurnLeft(turtleVec)
  653.                 else
  654.                     loc_TurnRight(turtleVec)
  655.                 end
  656.             end
  657.             if not (j == lenRight and i == lenForward) then
  658.                 loc_MoveForward(turtlePos, turtleVec)
  659.                 rowCnt = rowCnt + 1
  660.             end
  661.         end
  662.     end
  663. end
  664.  
  665. -- Gets material to make it waterproof
  666. function checkAndGetMaterial(deltaF, deltaU)
  667.     local neededMaterial = 2 * deltaF
  668.     if deltaU == 2 then
  669.         neededMaterial = deltaF
  670.     elseif deltaU == 1 then
  671.         neededMaterial = 0
  672.         return
  673.     end
  674.    
  675.     local numBuildMaterial = 0
  676.     for i=1, 16, 1 do
  677.         local numItems = turtle.getItemCount(i)
  678.         if numItems > 0 then
  679.             turtle.select(i)
  680.             local itemDetail = turtle.getItemDetail()
  681.             if itemDetail then
  682.                 if varInArr(itemDetail.name, building_material) then
  683.                     numBuildMaterial = numBuildMaterial + numItems
  684.                 end
  685.             end
  686.         end
  687.     end
  688.     if numBuildMaterial < neededMaterial then
  689.         local difference = neededMaterial - numBuildMaterial
  690.         print("More Material neede.")
  691.         if difference == 1 then
  692.             print("Pls put in 1 more block of building material.")
  693.         elseif difference == neededMaterial then
  694.             print("Pls put in ", difference, " blocks of building material.")
  695.         else
  696.             print("Pls put in ", difference, " more blocks of building material.")
  697.         end
  698.        
  699.         io.read()
  700.         checkAndGetMaterial(deltaF, deltaU)
  701.     end
  702. end
  703.  
  704. function placeUp()
  705.     selectItemFromList(building_material)
  706.     turtle.placeUp()
  707. end
  708. function placeDown()
  709.     selectItemFromList(building_material)
  710.     turtle.placeDown()
  711. end
  712.  
  713.  
  714.  
  715.  
  716. function topBottomRowProofer()
  717.     for i=1, deltaForward, 1 do
  718.         checkAndRefuel()
  719.         placeUp()
  720.         placeDown()
  721.         if i < deltaForward then
  722.             loc_MoveForward(turtlePos, turtleVec)
  723.         end
  724.     end
  725.  
  726.     loc_TurnLeft(turtleVec)
  727.     loc_TurnLeft(turtleVec)
  728.  
  729.     for i=1, deltaForward, 1 do
  730.         checkAndRefuel()
  731.         turtle.digUp()
  732.         turtle.digDown()
  733.         if i < deltaForward then
  734.             loc_MoveForward(turtlePos, turtleVec)
  735.         end
  736.     end
  737. end
  738.  
  739. function topRowProofer()
  740.     for i=1, deltaForward, 1 do
  741.         checkAndRefuel()
  742.         placeUp()
  743.         if i < deltaForward then
  744.             loc_MoveForward(turtlePos, turtleVec)
  745.         end
  746.     end
  747.  
  748.     loc_TurnLeft(turtleVec)
  749.     loc_TurnLeft(turtleVec)
  750.  
  751.     for i=1, deltaForward, 1 do
  752.         checkAndRefuel()
  753.         turtle.digUp()
  754.         if i < deltaForward then
  755.             loc_MoveForward(turtlePos, turtleVec)
  756.         end
  757.     end
  758. end
  759.  
  760. function bottomRowProofer()
  761.     for i=1, deltaForward, 1 do
  762.         checkAndRefuel()
  763.         placeDown()
  764.         if i < deltaForward then
  765.             loc_MoveForward(turtlePos, turtleVec)
  766.         end
  767.     end
  768.  
  769.     loc_TurnLeft(turtleVec)
  770.     loc_TurnLeft(turtleVec)
  771.  
  772.     for i=1, deltaForward, 1 do
  773.         checkAndRefuel()
  774.         turtle.digDown()
  775.         if i < deltaForward then
  776.             loc_MoveForward(turtlePos, turtleVec)
  777.         end
  778.     end
  779. end
  780.  
  781.  
  782.  
  783. function proofForwardPlane()
  784.     local remaining_height = deltaUp
  785.  
  786.     bStartPlane = true
  787.    
  788.     if remaining_height >= 1 then
  789.         for i=1, remaining_height - 2, 1 do
  790.             loc_MoveUp(turtlePos, turtleVec)
  791.         end
  792.         while remaining_height >= 2 do
  793.             if not bStartPlane then
  794.                 loc_TurnLeft(turtleVec)
  795.             end
  796.             loc_TurnLeft(turtleVec)
  797.             if remaining_height == 3 then
  798.                 topBottomRowProofer()
  799.             elseif deltaUp == 2 then
  800.                 topRowProofer()
  801.                 loc_TurnLeft(turtleVec)
  802.                 loc_TurnLeft(turtleVec)
  803.                 loc_MoveUp(turtlePos, turtleVec)
  804.                 bottomRowProofer()
  805.                 loc_MoveDown(turtlePos, turtleVec)
  806.             else
  807.                 topRowProofer()
  808.             end
  809.             remaining_height = remaining_height - 1
  810.            
  811.             if remaining_height > 1 then
  812.                 loc_MoveDown(turtlePos, turtleVec)
  813.             end
  814.             bStartPlane = false
  815.         end
  816.     end
  817. end
  818.  
  819.  
  820. digArea(mode, deltaForward, deltaRight, deltaUp)
  821.  
  822. goToStart()
  823. tryOffloadItems()
  824.  
  825. if bWaterproof then
  826.     checkAndGetMaterial(deltaForward, deltaUp)
  827.     loc_TurnLeft(turtleVec)
  828.     for i=1, deltaRight, 1 do
  829.         proofForwardPlane()
  830.         if i < deltaRight then
  831.             loc_TurnLeft(turtleVec)
  832.             loc_MoveForward(turtlePos, turtleVec)
  833.         end
  834.     end
  835.     print(turtlePos[1], turtlePos[2], turtlePos[3])
  836.     goToStart()
  837. end
  838.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement