Blackhome

Advanced Movement

Feb 5th, 2026 (edited)
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.03 KB | Gaming | 0 0
  1.     -- pastebin get Z5rK8b3r Advanced Movement
  2.    
  3.     BM = require("BM")
  4.     POS = require("POS")
  5.  
  6.     AM = {}
  7.  
  8.     local function isTurtleBlock(data)
  9.         return data and type(data.name) == "string" and data.name:match("computercraft:turtle")
  10.     end
  11.  
  12.     function AM.joinQueue()
  13.         local initData = SDM.TURTLE.loadInitData()
  14.         local finishCoord = initData.diskFinishCoord
  15.         finishCoord.y = initData.diskFinishCoord.y + 1
  16.         if not CVF.equalCoords(POS.position, finishCoord) then return false end
  17.  
  18.         BM.turnInDirection("BACKWARD")
  19.  
  20.         local level = 0
  21.         while true do
  22.             local success, data = turtle.inspect()
  23.             if not (success and isTurtleBlock(data)) then
  24.                 while not BM.forward() do sleep(0.5) end
  25.                 print("\nEntering queue...")
  26.                 if level % 2 == 0 then
  27.                     BM.turnInDirection("RIGHT")
  28.                 else
  29.                     BM.turnInDirection("LEFT")
  30.                 end
  31.                 break
  32.             else
  33.                 while not BM.up() do sleep(0.1) end
  34.                 level = level + 1
  35.             end
  36.         end
  37.  
  38.         SDM.TURTLE.setQueueState(true)
  39.     end
  40.  
  41.     function AM.queueForTask()
  42.         if not SDM.TURTLE.getQueueState() then return false end
  43.  
  44.         local initData = SDM.TURTLE.loadInitData()        
  45.         local taskOutputCoord = {x = initData.diskOutCoord.x, y = initData.diskOutCoord.y + 1, z = initData.diskOutCoord.z}
  46.  
  47.         while true do
  48.             local level = POS.position.y - initData.diskFinishCoord.y - 1
  49.  
  50.             local posQueueLeft = CVF.sub(initData.diskFinishCoord, initData.dirSection)
  51.             local posQueueRight = CVF.add(posQueueLeft, CVF.mult(4, initData.dirTopBelt))
  52.  
  53.             posQueueLeft.y = POS.position.y
  54.             posQueueRight.y = POS.position.y
  55.  
  56.             if level % 2 == 0 then
  57.                 BM.turnInDirection("RIGHT")
  58.                 if level == 0 then
  59.                     local bFirst = true
  60.                     while not CVF.equalCoords(taskOutputCoord, POS.position) do
  61.                         if not BM.forward() then
  62.                             sleep(0.5)
  63.                         end
  64.                     end
  65.                     print("Exiting Queue")
  66.                     break
  67.                 end
  68.  
  69.                 while not CVF.equalCoords(posQueueRight, POS.position) do
  70.                     if not BM.forward() then sleep(0.5) end
  71.                 end
  72.                 while not BM.down() do sleep(0.5) end
  73.                 level = level - 1
  74.             else
  75.                 BM.turnInDirection("LEFT")
  76.                 while not CVF.equalCoords(posQueueLeft, POS.position) do
  77.                     if not BM.forward() then sleep(0.5) end
  78.                 end
  79.                 while not BM.down() do sleep(0.5) end
  80.                 level = level - 1
  81.             end
  82.         end
  83.  
  84.         SDM.TURTLE.setQueueState(false)
  85.         return true
  86.     end
  87.  
  88.     function AM.reachChestPlacementCoord(targPos)
  89.         local initData = SDM.TURTLE.loadInitData()
  90.        
  91.         local targSection = POS.getSection(targPos)
  92.         local d1 = (targPos[POS.sectionDir] - POS.position[POS.sectionDir]) * initData.dirSection[POS.sectionDir]
  93.  
  94.         if POS.position.x ~= targPos.x or POS.position.z ~= targPos.z then
  95.             while POS.position.y % initData.blockHeight ~= (initData.lowBeltY + 6) % initData.blockHeight do
  96.                 BM.up()
  97.             end
  98.         end
  99.  
  100.         local d2 = (targPos[POS.beltDir] - POS.position[POS.beltDir]) * initData.dirTopBelt[POS.beltDir]
  101.  
  102.         if d2 < 0 then
  103.             BM.turnInDirection("LEFT")
  104.             while targPos[POS.beltDir] ~= POS.position[POS.beltDir] do
  105.                 while not BM.forward() do sleep(0.1) end
  106.             end
  107.         elseif d2 > 0 then
  108.             BM.turnInDirection("RIGHT")
  109.             while targPos[POS.beltDir] ~= POS.position[POS.beltDir] do
  110.                 while not BM.forward() do sleep(0.1) end
  111.             end
  112.         end
  113.         BM.turnInDirection("FORWARD")
  114.  
  115.         if d1 > 0 then
  116.             while targPos[POS.sectionDir] ~= POS.position[POS.sectionDir] do
  117.                 while not BM.forward() do sleep(0.1) end
  118.             end
  119.         else
  120.             while targPos[POS.sectionDir] ~= POS.position[POS.sectionDir] do
  121.                 while not BM.back() do sleep(0.1) end
  122.             end
  123.         end
  124.         while targPos.y > POS.position.y - 1 do
  125.             while not BM.up() do sleep(0.1) end
  126.         end
  127.         while targPos.y < POS.position.y - 1 do
  128.             while not BM.down() do sleep(0.1) end
  129.         end
  130.     end
  131.     -----------------------------------------------------------------------------------
  132.     -- joinBeltFromOutside      - joins lower belt
  133.     -- reachOutsideTarget       - reaches outside target if on route
  134.     -----------------------------------------------------------------------------------
  135.     function AM.joinBeltFromOutside()
  136.         if POS.isInBounds() then return false end
  137.  
  138.         local initData = SDM.TURTLE.loadInitData()
  139.         local B_Dir = POS.beltDir
  140.         local S_Dir = POS.sectionDir
  141.  
  142.         if POS.position[B_Dir] % 2 ~= initData.entryModulo then
  143.             BM.turnInDirection("LEFT")
  144.             while not BM.forward() do sleep(0.1) end
  145.         end
  146.  
  147.         while POS.position.y > initData.lowBeltY do
  148.             while not BM.down() do sleep(0.1) end
  149.         end
  150.         while POS.position.y < initData.lowBeltY do
  151.             while not BM.up() do sleep(0.1) end
  152.         end
  153.  
  154.         BM.turnInDirection("FORWARD")
  155.         while not POS.isOnBottomBelt() do
  156.             while not BM.forward() do sleep(0.1) end
  157.         end
  158.         BM.turnInDirection("LEFT")
  159.         return true
  160.     end
  161.     function AM.reachOutsideTarget(targPos)
  162.         if POS.isInBounds(targPos) then return false end
  163.         local initData = SDM.TURTLE.loadInitData()
  164.         local B_Dir = POS.beltDir
  165.         local S_Dir = POS.sectionDir
  166.  
  167.         local d1 = (POS.position[S_Dir] - targPos[S_Dir]) * initData.dirTopBelt[S_Dir]
  168.         if d1 < 0 then return false end
  169.        
  170.         if targPos[B_Dir] % 2 == initData.exitModulo then
  171.             if POS.position[B_Dir] ~= targPos[B_Dir] then
  172.                 return false
  173.             end
  174.             if POS.position[S_Dir] ~= targPos[S_Dir] and POS.position.y ~= initData.lowBeltY then
  175.                 return false
  176.             end
  177.             if POS.position.y > initData.lowBeltY and targPos.y < POS.position.y then
  178.                 return false
  179.             end
  180.             if POS.position.y < initData.lowBeltY and targPos.y > POS.position.y then
  181.                 return false
  182.             end
  183.         elseif targPos[B_Dir] % 2 ~= initData.exitModulo then
  184.             if POS.position[B_Dir] ~= targPos[B_Dir] + initData.dirTopBelt[B_Dir] then
  185.                 return false
  186.             end
  187.             if POS.position[S_Dir] ~= targPos[S_Dir] and POS.position.y ~= initData.lowBeltY then
  188.                 return false
  189.             end
  190.             if POS.position.y > initData.lowBeltY and targPos.y < POS.position.y then
  191.                 return false
  192.             end
  193.             if POS.position.y < initData.lowBeltY and targPos.y > POS.position.y then
  194.                 return false
  195.             end
  196.         end
  197.        
  198.         BM.turnInDirection("BACKWARD")
  199.        
  200.         while POS.position[S_Dir] ~= targPos[S_Dir] do
  201.             while not BM.forward() do sleep(0.1) end
  202.         end
  203.         while POS.position.y > targPos.y do
  204.             while not BM.down() do sleep(0.1) end
  205.         end
  206.         while POS.position.y < targPos.y do
  207.             while not BM.up() do sleep(0.1) end
  208.         end
  209.  
  210.  
  211.         if POS.position[B_Dir] ~= targPos[B_Dir] then
  212.             BM.turnInDirection("LEFT")
  213.             while not BM.forward() do sleep(0.1) end
  214.             BM.turnInDirection("FORWARD")
  215.         end
  216.  
  217.         if CVF.equalCoords(targPos, POS.position) then
  218.             return true
  219.         end
  220.         return false
  221.     end
  222.     -----------------------------------------------------------------------------------
  223.     -- switchBelts          - switches the belts by using the elevators
  224.     -- useAndExitBelt       - reaches belt exit (elevator or right exitmodulo)
  225.     -----------------------------------------------------------------------------------
  226.     function AM.switchBelts()
  227.         if POS.isOnBottomBelt() then
  228.             if not POS.isOnBeltExitUp() then
  229.                 BM.turnInDirection("LEFT")
  230.             end
  231.             while not POS.isOnBeltExitUp() do
  232.                 while not (BM.up() or BM.forward()) do sleep(0.1) end
  233.                 if POS.isOnTopBelt() then
  234.                     BM.turnInDirection("RIGHT")
  235.                     return true
  236.                 end
  237.             end
  238.             BM.turnInDirection("FORWARD")
  239.             while not BM.forward() do sleep(0.1) end
  240.             while not BM.up() do sleep(0.1) end
  241.             while not BM.back() do sleep(0.1) end
  242.             BM.turnInDirection("RIGHT")
  243.             return true
  244.         elseif POS.isOnTopBelt() then
  245.             if not POS.isOnBeltExitDown() then
  246.                 BM.turnInDirection("RIGHT")
  247.             end
  248.             while not POS.isOnBeltExitDown() do
  249.                 while not (BM.down() or BM.forward()) do sleep(0.1) end
  250.                 if POS.isOnBottomBelt() then
  251.                     BM.turnInDirection("LEFT")
  252.                     return true
  253.                 end
  254.             end
  255.             BM.turnInDirection("FORWARD")
  256.             while not BM.forward() do sleep(0.1) end
  257.             while not BM.down() do sleep(0.1) end
  258.             while not BM.back() do sleep(0.1) end
  259.             BM.turnInDirection("LEFT")
  260.             return true
  261.         end
  262.         return false
  263.     end
  264.     function AM.useAndExitBelt(targPos)
  265.         local initData = SDM.TURTLE.loadInitData()
  266.         if not POS.isInBounds(targPos) then
  267.             local exitPos = targPos[POS.beltDir]
  268.             if exitPos % 2 ~= initData.exitModulo then
  269.                 exitPos = exitPos + initData.dirTopBelt[POS.beltDir]
  270.             end
  271.             local d1 = (exitPos - POS.position[POS.beltDir]) * initData.dirTopBelt[POS.beltDir]
  272.             if d1 > 0 then                      -- exit on right
  273.                 if POS.isOnBottomBelt() then
  274.                     AM.switchBelts()
  275.                 end
  276.                 BM.turnInDirection("RIGHT")
  277.             elseif d1 < 0 then                  -- exit on left
  278.                 if POS.isOnTopBelt() then
  279.                     AM.switchBelts()
  280.                 end
  281.                 BM.turnInDirection("LEFT")
  282.             end
  283.  
  284.             while not (POS.position[POS.beltDir] == exitPos) do
  285.                 while not BM.forward() do sleep(0.1) end
  286.             end
  287.            
  288.             if POS.isOnTopBelt() then
  289.                 AM.switchBelts()
  290.                 while not (POS.position[POS.beltDir] == exitPos) do
  291.                     while not BM.forward() do sleep(0.1) end
  292.                 end
  293.             end
  294.             BM.turnInDirection("BACKWARD")
  295.             while not BM.forward() do sleep(0.1) end
  296.  
  297.             return true
  298.         end
  299.         if POS.isOnBottomBelt(targPos) or POS.isOnTopBelt(targPos) then
  300.             local d1 = (targPos[POS.beltDir] - POS.position[POS.beltDir]) * initData.dirTopBelt[POS.beltDir]
  301.             if d1 > 0 and POS.isOnBottomBelt() then
  302.                 AM.switchBelts()
  303.             elseif d1 < 0 and POS.isOnTopBelt() then
  304.                 AM.switchBelts()
  305.             end
  306.             while targPos[POS.beltDir] ~= POS.position[POS.beltDir] do
  307.                 while not BM.forward() do sleep(0.1) end
  308.             end
  309.             if targPos.y ~= POS.position.y then
  310.                 AM.switchBelts()
  311.                 while targPos[POS.beltDir] ~= POS.position[POS.beltDir] do
  312.                     while not BM.forward() do sleep(0.1) end
  313.                 end
  314.             end
  315.             return true
  316.         end
  317.         local turtSection = POS.getSection()
  318.         local targSection = POS.getSection(targPos)
  319.  
  320.         local targSecHeight = POS.getSectionHeight(targPos)
  321.         local exitPos = targSection
  322.         local bUp = true
  323.  
  324.         if targSecHeight > initData.lowBeltY then
  325.             exitPos = exitPos + initData.dirTopBelt[POS.beltDir]
  326.         elseif targSecHeight < initData.lowBeltY then
  327.             exitPos = exitPos + initData.dirBottomBelt[POS.beltDir]
  328.             bUp = false
  329.         else
  330.             bUp = false
  331.         end
  332.         local d1 = (exitPos - POS.position[POS.beltDir]) * initData.dirTopBelt[POS.beltDir]
  333.  
  334.         if d1 > 0 and exitPos == targSection then
  335.             exitPos = exitPos - initData.dirTopBelt[POS.beltDir]
  336.         end
  337.  
  338.         if d1 > 0 and POS.isOnBottomBelt() then
  339.             AM.switchBelts()
  340.         end
  341.         if d1 < 0 and POS.isOnTopBelt() then
  342.             AM.switchBelts()
  343.         end
  344.  
  345.         if POS.isOnBottomBelt() then BM.turnInDirection("LEFT") end
  346.         if POS.isOnTopBelt() then BM.turnInDirection("RIGHT") end
  347.  
  348.         while exitPos ~= POS.position[POS.beltDir] do
  349.             while not BM.forward() do sleep(0.1) end
  350.         end
  351.  
  352.         if POS.isOnBottomBelt() and not bUp and not (exitPos == targSection) then
  353.             AM.switchBelts()
  354.             BM.turnInDirection("RIGHT")
  355.             while exitPos ~= POS.position[POS.beltDir] do
  356.                 while not BM.forward() do sleep(0.1) end
  357.             end
  358.         elseif POS.isOnTopBelt() and bUp then
  359.             AM.switchBelts()
  360.             BM.turnInDirection("LEFT")
  361.             while exitPos ~= POS.position[POS.beltDir] do
  362.                 while not BM.forward() do sleep(0.1) end
  363.             end
  364.         end
  365.  
  366.         BM.turnInDirection("FORWARD")
  367.         while not BM.forward() do sleep(0.1) end
  368.  
  369.         return true
  370.     end
  371.  
  372.  
  373.     function AM.useElevatorUp(targPos)
  374.         if not POS.isOnElevatorUp() then return false end
  375.        
  376.         local initData = SDM.TURTLE.loadInitData()
  377.  
  378.         local turtSection = POS.getSection()
  379.         local targSection = POS.getSection(targPos)
  380.  
  381.         local targSecHeight = POS.getSectionHeight(targPos)
  382.  
  383.         if type(targSection) == "string" then
  384.             targSection = targPos[POS.beltDir]
  385.             if targSection == turtSection then
  386.                 targSection = targSection + initData.dirBottomBelt[POS.beltDir]
  387.             end
  388.             targSecHeight = initData.lowBeltY
  389.         end
  390.         if POS.isOnElevatorDown(targPos) then targSecHeight = targSecHeight + initData.blockHeight end
  391.  
  392.         local d1 = (targSection - turtSection) * initData.dirTopBelt[POS.beltDir]
  393.  
  394.         if turtSection ~= targSection then
  395.             if POS.position.y <= initData.lowBeltY + 1 then
  396.                 while POS.position.y ~=  initData.lowBeltY + 1 do
  397.                     while not BM.up() do sleep(0.1) end
  398.                 end
  399.                 BM.turnInDirection("BACKWARD")
  400.                 while not BM.forward() do sleep(0.1) end
  401.                 return
  402.             end
  403.             while POS.position.y % 8 ~= initData.lowBeltY % 8 do
  404.                 while not BM.up() do sleep(0.1) end
  405.             end
  406.             BM.turnInDirection("LEFT")
  407.             while not BM.forward() do sleep(0.1) end
  408.             return
  409.         end
  410.  
  411.         if POS.isOnElevatorUp(targPos)then
  412.             if targPos.y >= POS.position.y then
  413.                 while targPos.y ~= POS.position.y do
  414.                     while not BM.up() do sleep(0.1) end
  415.                 end
  416.             else
  417.                 while POS.position.y % 8 ~= initData.lowBeltY % 8 do
  418.                     while not BM.up() do sleep(0.1) end
  419.                 end
  420.                 BM.turnInDirection("LEFT")
  421.                 while not BM.forward() do sleep(0.1) end
  422.             end
  423.             return
  424.         end
  425.  
  426.         while targSecHeight > POS.position.y do
  427.             while not BM.up() do sleep(0.1) end
  428.         end
  429.         while POS.position.y % 8 ~= initData.lowBeltY % 8 do
  430.             while not BM.up() do sleep(0.1) end
  431.         end
  432.         BM.turnInDirection("LEFT")
  433.         while not BM.forward() do sleep(0.1) end
  434.         return
  435.     end
  436.  
  437.     -- Turtle_ST = require("Turtle_ST")
  438.     function AM.useElevatorDown(targPos)
  439.         if not POS.isOnElevatorDown() then return false end
  440.        
  441.         local initData = SDM.TURTLE.loadInitData()
  442.  
  443.         local turtSection = POS.getSection()
  444.         local targSection = POS.getSection(targPos)
  445.  
  446.         local targSecHeight = POS.getSectionHeight(targPos)
  447.  
  448.         if type(targSection) == "string" then
  449.             targSection = targPos[POS.beltDir]
  450.             if targSection == turtSection then
  451.                 targSection = targSection + initData.dirTopBelt[POS.beltDir]
  452.             end
  453.             targSecHeight = initData.lowBeltY
  454.         end
  455.         if POS.isOnElevatorUp(targPos) then targSecHeight = targSecHeight - initData.blockHeight end
  456.  
  457.         local d1 = (targSection - turtSection) * initData.dirTopBelt[POS.beltDir]
  458.  
  459.         if turtSection ~= targSection then
  460.             if POS.position.y >= initData.lowBeltY then
  461.                 while POS.position.y ~=  initData.lowBeltY do
  462.                     while not BM.down() do sleep(0.1) end
  463.                 end
  464.                 BM.turnInDirection("BACKWARD")
  465.                 while not BM.forward() do sleep(0.1) end
  466.                 return
  467.             end
  468.             while POS.position.y % 8 ~= initData.lowBeltY % 8 do
  469.                 while not BM.down() do sleep(0.1) end
  470.             end
  471.             BM.turnInDirection("RIGHT")
  472.             while not BM.forward() do sleep(0.1) end
  473.             return
  474.         end
  475.  
  476.         if POS.isOnElevatorDown(targPos)then
  477.             if targPos.y <= POS.position.y then
  478.                 while targPos.y ~= POS.position.y do
  479.                     while not BM.down() do sleep(0.1) end
  480.                 end
  481.             else
  482.                 while POS.position.y % 8 ~= initData.lowBeltY % 8 do
  483.                     while not BM.down() do sleep(0.1) end
  484.                 end
  485.                 BM.turnInDirection("RIGHT")
  486.                 while not BM.forward() do sleep(0.1) end
  487.             end
  488.             return
  489.         end
  490.  
  491.         while targSecHeight < POS.position.y do
  492.             while not BM.down() do sleep(0.1) end
  493.         end
  494.         while POS.position.y % 8 ~= initData.lowBeltY % 8 do
  495.             while not BM.down() do sleep(0.1) end
  496.         end
  497.         BM.turnInDirection("RIGHT")
  498.         while not BM.forward() do sleep(0.1) end
  499.         return
  500.     end
  501.  
  502.     function AM.useBottomSection(targPos)
  503.         if not POS.isOnBottomSection() then return false end
  504.  
  505.         local initData = SDM.TURTLE.loadInitData()
  506.  
  507.         local turtSection = POS.getSection()
  508.         local targSection = POS.getSection(targPos)
  509.  
  510.         local targSecHeight = POS.getSectionHeight(targPos)
  511.         local turtSecHeight = POS.getSectionHeight()
  512.  
  513.         local d1 = (targPos[POS.sectionDir] - POS.position[POS.sectionDir]) * initData.dirSection[POS.sectionDir]
  514.  
  515.         local exception1 = targSection ~= turtSection
  516.         local exception2 = targSecHeight ~= turtSecHeight
  517.         local exception3 = d1 < 0
  518.  
  519.         if d1 ~= 0 or POS.isOnElevatorUp(targPos) or POS.isOnElevatorDown(targPos) then
  520.             BM.turnInDirection("FORWARD")
  521.         end
  522.  
  523.         if exception1 or exception2 or exception3 then
  524.             while not BM.forward() do sleep(0.1) end
  525.             while not BM.forward() do sleep(0.1) end
  526.             BM.turnInDirection("LEFT")
  527.             while not BM.forward() do sleep(0.1) end
  528.             return
  529.         end
  530.  
  531.         while targPos[POS.sectionDir] ~= POS.position[POS.sectionDir] do
  532.             while not BM.forward() do sleep(0.1) end
  533.         end
  534.  
  535.         local d2 = (targPos[POS.beltDir] - POS.position[POS.beltDir]) * initData.dirTopBelt[POS.beltDir]
  536.  
  537.         if d2 > 0 then BM.turnInDirection("RIGHT") end
  538.         if d2 < 0 then BM.turnInDirection("LEFT") end
  539.         if d2 == 0 then return end
  540.  
  541.         while not BM.forward() do sleep(0.1) end
  542.         return
  543.     end
  544.  
  545.     function AM.useChestRow(targPos)
  546.         if not (POS.isOnLeftChestRow() or POS.isOnRightChestRow()) then return end
  547.        
  548.         local initData = SDM.TURTLE.loadInitData()
  549.  
  550.         local targSecHeight = POS.getSectionHeight(targPos)
  551.         local turtSecHeight = POS.getSectionHeight()
  552.  
  553.         local exception1 = targPos[POS.sectionDir] ~= POS.position[POS.sectionDir]
  554.         local exception2 = targPos[POS.beltDir] ~= POS.position[POS.beltDir]
  555.         local exception3 = targPos.y < POS.position.y
  556.         local exception4 = targSecHeight ~= turtSecHeight
  557.  
  558.         if exception1 or exception2 or exception3 or exception4 then
  559.             while not POS.isOnHighestChestRow() do
  560.                 while not BM.up() do sleep(0.1) end
  561.             end
  562.  
  563.             if POS.isOnLeftChestRow() then BM.turnInDirection("LEFT") end
  564.             if POS.isOnRightChestRow() then BM.turnInDirection("RIGHT") end
  565.  
  566.             while not BM.back() do sleep(0.1) end
  567.  
  568.             BM.turnInDirection("BACKWARD")
  569.             return
  570.         end
  571.  
  572.         while targPos.y ~= POS.position.y do
  573.             while not BM.up() do sleep(0.1) end
  574.         end
  575.         return
  576.     end
  577.  
  578.     function AM.useTopSection(targPos)
  579.         if not POS.isOnTopsection() then return end
  580.  
  581.         local initData = SDM.TURTLE.loadInitData()
  582.         local elevatorPos = initData.initChestCoord[POS.sectionDir] - initData.dirSection[POS.sectionDir]
  583.  
  584.         local targSecHeight = POS.getSectionHeight(targPos)
  585.  
  586.         local turtSection = POS.getSection()
  587.         local targSection = POS.getSection(targPos)
  588.  
  589.         BM.turnInDirection("BACKWARD")
  590.         while POS.position[POS.sectionDir] ~= elevatorPos do
  591.             while not BM.forward() do sleep(0.1) end
  592.         end
  593.  
  594.         if POS.position.y > initData.lowBeltY then
  595.             if targSecHeight > POS.position.y and targSection == turtSection then
  596.                 BM.turnInDirection("RIGHT")
  597.             else
  598.                 BM.turnInDirection("LEFT")
  599.             end
  600.         elseif POS.position.y < initData.lowBeltY then
  601.             if targSecHeight < POS.position.y and targSection == turtSection then
  602.                 BM.turnInDirection("LEFT")
  603.             else
  604.                 BM.turnInDirection("RIGHT")
  605.             end
  606.         end
  607.         while not BM.forward() do sleep(0.1) end
  608.  
  609.         return
  610.     end
  611.  
  612.    
  613.     -- turtle.back() TURT = require("TURT") TURT.init()
  614.     -- t = {x=-50, y=72, z=-28}
  615.     -- t = {x=-45, y=77, z=-18}
  616.     function AM.goToCoord(targPos)
  617.         if CVF.equalCoords(targPos, POS.position) then return true end
  618.  
  619.         term.clear()
  620.         term.setCursorPos(1, 1)
  621.  
  622.         local bTurtleInBounds = POS.isInBounds()
  623.         local bTargetInBounds = POS.isInBounds(targPos)
  624.  
  625.         local startPos = {x=POS.position.x, y=POS.position.y, z=POS.position.z}
  626.  
  627.         if not POS.isInBounds() then
  628.             print("Out Bounds")
  629.             if not AM.reachOutsideTarget(targPos) then
  630.                 AM.joinBeltFromOutside(targPos)              -- Not ready
  631.             else
  632.                 return true
  633.             end
  634.         end
  635.         if POS.isOnBottomBelt() or POS.isOnTopBelt() then
  636.             print("On Belt")
  637.             AM.useAndExitBelt(targPos)
  638.         end
  639.  
  640.         if POS.isOnElevatorUp() then
  641.             print("On Elevator Up")
  642.             AM.useElevatorUp(targPos)
  643.         end
  644.         if POS.isOnElevatorDown() then
  645.             print("On Elevator Down")
  646.             AM.useElevatorDown(targPos)
  647.         end
  648.  
  649.         if POS.isOnBottomSection() then
  650.             print("On Bottom Section")
  651.             AM.useBottomSection(targPos)
  652.         end
  653.  
  654.         if POS.isOnLeftChestRow() or POS.isOnRightChestRow() then
  655.             print("On Chest Row")
  656.             AM.useChestRow(targPos)
  657.         end
  658.  
  659.         if POS.isOnTopsection() then
  660.             print("On Top Section")
  661.             AM.useTopSection(targPos)
  662.         end
  663.  
  664.         if CVF.equalCoords(startPos, POS.position) then return false end
  665.  
  666.         return AM.goToCoord(targPos)
  667.  
  668.     end
  669.  
  670.     return AM
Advertisement
Add Comment
Please, Sign In to add comment