Advertisement
starkrights

utils.lua

May 27th, 2024
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 KB | None | 0 0
  1. startX = 728
  2. startY = 253
  3. startZ = -169
  4.  
  5.  
  6. function gotoChunkCenter()
  7.     print("Relocating to chunk center...")
  8.     local x,y,z = gps.locate()
  9.     while x ~= startX or z ~= startZ do
  10.         x,y,z = gps.locate()
  11.         turtle.refuel()
  12.             if x ~= startX then
  13.                 if x > startX then
  14.                     turtle.back()
  15.                 else
  16.                     turtle.forward()
  17.                 end
  18.             end
  19.            
  20.             if z ~= startZ then
  21.                 turtle.turnRight()
  22.                 if z > startZ then
  23.                     turtle.back()
  24.                 else
  25.                     turtle.forward()
  26.                 end
  27.                 turtle.turnLeft()
  28.             end
  29.     end
  30.     print("  Reached chunk center.")
  31. end
  32.  
  33. RelativePosition = {x = 0, y = 0, z = 0}
  34. function RelativePosition:new ()
  35.     self.x = 0
  36.     self.y = 0
  37.     self.z = 0
  38.     return self
  39. end
  40.  
  41. BLOCK_IDS = {
  42.     digiminer = "mekanism:digital_miner",
  43.     tesseract = "mekanism:quantum_entangloporter",
  44.     fluxpoint = "fluxnetworks:flux_point"
  45. }
  46. function findItemSlot(itemName)
  47.     print("Finding item '"..itemName.."'...")
  48.     for i=1,16 do
  49.         print("  Testing slot "..i)
  50.         turtle.select(i)
  51.         item = turtle.getItemDetail()
  52.         if item then
  53.             print("    - Slot contains "..item.name)
  54.             if item.name == itemName then
  55.                 return i
  56.             end
  57.         else
  58.             print("    - Slot is nil")
  59.         end
  60.     end
  61.     return -1
  62. end
  63.  
  64. function constructDigiminerComplex()
  65.     print("Constructing digiminer complex...")
  66.     digiminerSlot = findItemSlot(BLOCK_IDS.digiminer)
  67.     tesseractSlot = findItemSlot(BLOCK_IDS.tesseract)
  68.     fluxpointSlot = findItemSlot(BLOCK_IDS.fluxpoint)
  69.     --- place digiminer
  70.     turtle.select(digiminerSlot)
  71.     turtle.placeUp()
  72.    
  73.     --- place entangloporter
  74.     turtle.forward()
  75.     turtle.forward()
  76.     turtle.up()
  77.     turtle.select(tesseractSlot)
  78.     turtle.placeUp()
  79.  
  80.     --- place fluxpoint
  81.     turtle.turnRight()
  82.     turtle.forward()
  83.     turtle.forward()
  84.     turtle.select(fluxpointSlot)
  85.     turtle.placeUp()
  86.     turtle.back()
  87.     turtle.back()
  88.     turtle.turnLeft()
  89.  
  90.     print("  Digiminer complex constructed. Homing...")
  91.     --- return to start
  92.     turtle.down()
  93.     turtle.back()
  94.     turtle.back()
  95.  
  96.     print("  Homed back to origin.")
  97. end
  98.  
  99.  
  100. gotoChunkCenter()
  101. constructDigiminerComplex()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement