Advertisement
starkrights

utils.lua

May 27th, 2024
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.02 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. }
  45. function findItemSlot(itemName)
  46.     print("Finding item '"..itemName.."'...")
  47.     for i=0,16 do
  48.         print("  Testing slot "..i)
  49.         turtle.select(i)
  50.         item = turtle.getItemDetail()
  51.         print("    - Slot contains "..item.name)
  52.         if item.name == itemName then
  53.             return i
  54.         end
  55.     end
  56.     return -1
  57. end
  58.  
  59. function constructDigiminerComplex()
  60.     print("Constructing digiminer complex...")
  61.     digiminerSlot = findItemSlot(BLOCK_IDS.digiminer)
  62.     tesseractSlot = findItemSlot(BLOCK_IDS.tesseract)
  63.     --- place digiminer
  64.     turtle.select(digiminerSlot)
  65.     turtle.placeUp()
  66.    
  67.     --- place entangloporter
  68.     turtle.forward()
  69.     turtle.forward()
  70.     turtle.up()
  71.     turtle.select(tesseractSlot)
  72.     turtle.placeUp()
  73.  
  74.     print("  Digiminer complex constructed. Homing...")
  75.     --- return to start
  76.     turtle.down()
  77.     turtle.back()
  78.     turtle.back()
  79.  
  80.     print("  Homed back to origin.")
  81. end
  82.  
  83.  
  84. gotoChunkCenter()
  85. constructDigiminerComplex()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement