Blackhome

ST Positioning

Feb 4th, 2026 (edited)
161
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.80 KB | Gaming | 0 0
  1.     -- pastebin get a22LsH3d Positioning
  2.  
  3.     SDM = require("SDM")
  4.     CVF = require("CVF")
  5.     POS = {}
  6.  
  7.     local initData = {}
  8.     POS.position = nil
  9.     POS.direction = nil
  10.  
  11.  
  12.     local TURTLE = SDM.TURTLE
  13.  
  14.     local sectionDir = ""
  15.     local beltDir = ""
  16.  
  17.     local varList = {
  18.                 "dirSection", "dirTopBelt", "dirBottomBelt", "initChestCoord", "yModulo",
  19.                 "chestRowMod", "chestColMod", "elevPos", "sectionMod", "leftSecMod",
  20.                 "rightSecMod", "lowBeltY", "upBeltY", "diskOutCoord", "diskFinishCoord",
  21.                 "entryModulo", "exitModulo", "pickaxeChestCoord", "chestOutCoord",
  22.                 "bLeftStart", "colBlockNum", "blockHeight", "beltPos", "chestRefuelCoord"
  23.         }
  24.     POS.sectionDir = ""
  25.     POS.beltDir = ""
  26.  
  27.     function POS.init()
  28.         initData = TURTLE.loadInitData()
  29.         if not initData then
  30.             print("Can't find Init Data")
  31.             return false, 1
  32.         end
  33.        
  34.         if not POS.get_GPS_Position() then
  35.             print("Can't locate Turtle")
  36.             return false, 2
  37.         end
  38.  
  39.         if CVF.isXDir(initData.dirSection) then
  40.             sectionDir = "x"
  41.             beltDir = "z"
  42.             POS.sectionDir = "x"
  43.             POS.beltDir = "z"
  44.         else
  45.             sectionDir = "z"
  46.             beltDir = "x"
  47.             POS.sectionDir = "z"
  48.             POS.beltDir = "x"
  49.         end
  50.  
  51.         if not POS.get_Direction() then
  52.             return false, 3
  53.         end
  54.  
  55.         return true
  56.     end
  57.  
  58.     function POS.get_GPS_Position()
  59.         local x, y, z = gps.locate()
  60.         if not x or not y or not z then
  61.             print("GPS not available.")
  62.             return false
  63.         end
  64.         POS.position = {x = math.floor(x), y = math.floor(y), z = math.floor(z)}
  65.         if not POS.position.x or not POS.position.y or not POS.position.z then
  66.             print("GPS not available.")
  67.             return false
  68.         end
  69.         return true
  70.     end
  71.  
  72.     function POS.get_Direction()
  73.         local disk, dPath = SDM.getDisk("init")
  74.         if disk then
  75.             POS.direction = initData.dirSection
  76.             return true
  77.         end
  78.         disk, dPath = SDM.getDisk("outgoing")
  79.         if disk then
  80.             for i=1, 4 do
  81.                 local success, data = turtle.inspect()
  82.                 if success and data.name == "minecraft:chest" then
  83.                     POS.direction = initData.dirTopBelt
  84.                     return true
  85.                 end
  86.                 turtle.turnRight()
  87.             end
  88.         end
  89.         return false
  90.     end
  91.  
  92.     function POS.isInBounds(pos)
  93.         if not pos then pos = POS.position end
  94.         local d1 = (pos[sectionDir] - initData.initChestCoord[sectionDir]) * initData.dirSection[sectionDir]
  95.  
  96.         return d1 >= -2
  97.     end
  98.  
  99.     function POS.isInSystem(pos)
  100.         if not pos then pos = POS.position end
  101.  
  102.         if POS.isOnBottomBelt(pos) then return true end
  103.         if POS.isOnTopBelt(pos) then return true end
  104.         if POS.isOnBottomSection(pos) then return true end
  105.         if POS.isOnTopsection(pos) then return true end
  106.         if POS.isOnLeftChestRow(pos) then return true end
  107.         if POS.isOnRightChestRow(pos) then return true end
  108.         if POS.isOnElevatorUp(pos) then return true end
  109.         if POS.isOnElevatorDown(pos) then return true end
  110.         if not POS.isInBounds(pos) then return true end
  111.         return false
  112.     end
  113.  
  114.     function POS.isOnBottomBelt(pos)
  115.         if not pos then pos = POS.position end
  116.         if not (pos.y == initData.lowBeltY) then return false end
  117.  
  118.         return initData.beltPos == pos[sectionDir]
  119.     end
  120.     function POS.isOnTopBelt(pos)
  121.         if not pos then pos = POS.position end
  122.         if not (pos.y == initData.upBeltY) then return false end
  123.  
  124.         return initData.beltPos == pos[sectionDir]
  125.     end
  126.  
  127.     function POS.isOnBottomSection(pos)
  128.         if not pos then pos = POS.position end
  129.         local d1 = (pos[sectionDir] - initData.initChestCoord[sectionDir]) * initData.dirSection[sectionDir]
  130.         local modYPos = pos.y % initData.blockHeight
  131.         local modYSection = initData.lowBeltY % initData.blockHeight
  132.  
  133.         if d1 < -1 then return false end
  134.         if not (pos[beltDir] % 8 == initData.sectionMod) then return false end
  135.  
  136.         return modYPos == modYSection
  137.     end
  138.  
  139.     function POS.isOnTopsection(pos)
  140.         if not pos then pos = POS.position end
  141.         local d1 = (pos[sectionDir] - initData.initChestCoord[sectionDir]) * initData.dirSection[sectionDir]
  142.         local modYPos = pos.y % initData.blockHeight
  143.         local modYSection = (initData.lowBeltY - (initData.blockHeight - 5)) % initData.blockHeight
  144.  
  145.         if d1 < -1 then return false end
  146.         if not (pos[beltDir] % 8 == initData.sectionMod) then return false end
  147.         return modYPos == modYSection
  148.     end
  149.  
  150.     function POS.isOnLeftChestRow(pos)
  151.         if not pos then pos = POS.position end
  152.         local d1 = (pos[sectionDir] - initData.initChestCoord[sectionDir]) * initData.dirSection[sectionDir]
  153.         if d1 < 0 then return false end
  154.  
  155.         return pos[beltDir] % 8 == initData.leftSecMod % 8
  156.     end
  157.     function POS.isOnRightChestRow(pos)
  158.         if not pos then pos = POS.position end
  159.         local d1 = (pos[sectionDir] - initData.initChestCoord[sectionDir]) * initData.dirSection[sectionDir]
  160.         if d1 < 0 then return false end
  161.  
  162.         return pos[beltDir] % 8 == initData.rightSecMod % 8
  163.     end
  164.     function POS.isOnHighestChestRow(pos)
  165.         if not (POS.isOnLeftChestRow(pos) or POS.isOnRightChestRow(pos)) then return false end
  166.         if not pos then pos = POS.position end
  167.  
  168.         local modYPos = pos.y % initData.blockHeight
  169.         local modYSection = (initData.lowBeltY - (initData.blockHeight - 5)) % initData.blockHeight
  170.  
  171.         return modYPos == modYSection
  172.     end
  173.  
  174.     function POS.isOnElevatorUp(pos)
  175.         if not pos then pos = POS.position end
  176.         local d1 = (pos[sectionDir] - initData.initChestCoord[sectionDir]) * initData.dirSection[sectionDir]
  177.         if d1 ~= -1 then return false end
  178.  
  179.         return pos[beltDir] % 8 == initData.rightSecMod % 8
  180.     end
  181.     function POS.isOnElevatorDown(pos)
  182.         if not pos then pos = POS.position end
  183.         local d1 = (pos[sectionDir] - initData.initChestCoord[sectionDir]) * initData.dirSection[sectionDir]
  184.         if d1 ~= -1 then return false end
  185.  
  186.         return pos[beltDir] % 8 == initData.leftSecMod % 8
  187.     end
  188.  
  189.     function POS.isOnBeltExitUp(pos)
  190.         if not pos then pos = POS.position end
  191.         local d1 = (pos[sectionDir] - initData.initChestCoord[sectionDir]) * initData.dirSection[sectionDir]
  192.         if d1 ~= -2 then return false end
  193.  
  194.         return pos[beltDir] % 8 == initData.rightSecMod % 8
  195.     end
  196.     function POS.isOnBeltExitDown(pos)
  197.         if not pos then pos = POS.position end
  198.         local d1 = (pos[sectionDir] - initData.initChestCoord[sectionDir]) * initData.dirSection[sectionDir]
  199.         if d1 ~= -2 then return false end
  200.  
  201.         return pos[beltDir] % 8 == initData.leftSecMod % 8
  202.     end
  203.  
  204.     function POS.getSection(pos)
  205.         if not pos then pos = POS.position end
  206.         local rAxisCoord = pos[beltDir]
  207.         local fAxisCoord = pos[sectionDir]
  208.         local d1 = (fAxisCoord - initData.initChestCoord[sectionDir]) * initData.dirSection[sectionDir]
  209.  
  210.         if d1 < -1 then return "out" end
  211.  
  212.         local testPos = {
  213.             [sectionDir] = fAxisCoord,
  214.             ["y"] = initData.lowBeltY,
  215.             [beltDir] = rAxisCoord
  216.         }
  217.         if POS.isOnBottomSection(testPos) then return testPos[beltDir] end
  218.  
  219.         testPos[beltDir] = rAxisCoord + 1
  220.         if POS.isOnBottomSection(testPos) then return testPos[beltDir] end
  221.         testPos[beltDir] = rAxisCoord - 1
  222.         if POS.isOnBottomSection(testPos) then return testPos[beltDir] end
  223.  
  224.         testPos[beltDir] = rAxisCoord + 2
  225.         if POS.isOnBottomSection(testPos) then return testPos[beltDir] end
  226.         testPos[beltDir] = rAxisCoord - 2
  227.         if POS.isOnBottomSection(testPos) then return testPos[beltDir] end
  228.  
  229.         testPos[beltDir] = rAxisCoord + 3
  230.         if POS.isOnBottomSection(testPos) then return testPos[beltDir] end
  231.         testPos[beltDir] = rAxisCoord - 3
  232.         if POS.isOnBottomSection(testPos) then return testPos[beltDir] end
  233.  
  234.         testPos[beltDir] = rAxisCoord + 4
  235.         if POS.isOnBottomSection(testPos) then return "center" end
  236.         return nil
  237.     end
  238.  
  239.     function POS.getSectionHeight(pos)
  240.         if not pos then pos = POS.position end
  241.         local yModulo = initData.lowBeltY % initData.blockHeight
  242.  
  243.         for dy = 0, initData.blockHeight - 1 do
  244.             if (pos.y - dy) % initData.blockHeight == yModulo then return (pos.y - dy) end
  245.         end
  246.         return nil
  247.     end
  248.  
  249.  
  250. return POS
  251.  
  252.  
Advertisement
Comments
  • User was banned
  • Gelmalir
    62 days
    # CSS 0.06 KB | 0 0
    1. You literally stole this exploit from https://t.me/theprotocolone
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment