Blackhome

FluidProofer

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