Advertisement
starkrights

utils.lua

May 27th, 2024
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.03 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.     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