Advertisement
starkrights

utils.lua

May 27th, 2024
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 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.     while x ~= startX or z ~= startZ do
  9.         local x,y,z = gps.locate()
  10.         turtle.refuel()
  11.             if x ~= startX then
  12.                 if x > startX then
  13.                     turtle.back()
  14.                 else
  15.                     turtle.forward()
  16.                 end
  17.             end
  18.            
  19.             if z ~= startZ then
  20.                 turtle.turnRight()
  21.                 if z > startZ then
  22.                     turtle.back()
  23.                 else
  24.                     turtle.forward()
  25.                 end
  26.                 turtle.turnLeft()
  27.             end
  28.             x,y,z = gps.locate()
  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. }
  45. function findItemSlot(itemName)
  46.     for i=0,16 do
  47.         item = turtle.getItemDetail()
  48.         if item.name == itemName then
  49.             return i
  50.         end
  51.     end
  52.     return -1
  53. end
  54.  
  55. function constructDigiminerComplex()
  56.     print("Constructing digiminer complex...")
  57.     digiminerSlot = findItemSlot(BLOCK_IDS.digiminer)
  58.     tesseractSlot = findItemSlot(BLOCK_IDS.tesseract)
  59.     --- place digiminer
  60.     turtle.select(digiminerSlot)
  61.     turtle.placeUp()
  62.    
  63.     --- place entangloporter
  64.     turtle.forward()
  65.     turtle.forward()
  66.     turtle.up()
  67.     turtle.select(tesseractSlot)
  68.     turtle.placeUp()
  69.  
  70.     print("  Digiminer complex constructed. Homing...")
  71.     --- return to start
  72.     turtle.down()
  73.     turtle.back()
  74.     turtle.back()
  75.  
  76.     print("  Homed back to origin.")
  77. end
  78.  
  79.  
  80. gotoChunkCenter()
  81. constructDigiminerComplex()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement