Advertisement
drpepper240

Multilaser test

Dec 5th, 2023 (edited)
828
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.49 KB | None | 0 0
  1. local lasers = {}
  2. lasers.A = {}
  3. lasers.B = {}
  4. lasers.C = {}
  5. lasers.D = {}
  6. local tmpLasers = {peripheral.find("warpdriveLaser")}
  7. for k,v in pairs(tmpLasers) do
  8.     if v.isInterfaced() then
  9.         v.lx, v.ly, v.lz = v.getLocalPosition()
  10.         v.beamFrequency(30000)
  11.         if (v.lz==-704) then
  12.             --main laser
  13.             if (v.lx == 326) then
  14.                 lasers.Amain = v
  15.             elseif (v.lx == 322) then
  16.                 lasers.Cmain = v
  17.             elseif (v.ly == 74) then
  18.                 lasers.Bmain = v
  19.             elseif (v.ly == 70) then
  20.                 lasers.Dmain = v
  21.             else
  22.                 print("wtf main")
  23.             end
  24.         elseif (v.lz==-703) then
  25.             --aux laser
  26.             if (v.lx >327) then
  27.                 table.insert(lasers.A, v)
  28.             elseif (v.lx < 321) then
  29.                 table.insert(lasers.C, v)
  30.             elseif (v.ly > 75) then
  31.                 table.insert(lasers.B, v)
  32.             elseif (v.ly < 69) then
  33.                 table.insert(lasers.D, v)
  34.             else
  35.                 print("wtf\n")
  36.             end
  37.         end
  38.     else
  39.         print("Found uninterfaced laser!")
  40.     end
  41. end
  42.  
  43. print("Test firing in 5 seconds")
  44. sleep (5)
  45.  
  46. local target = {}
  47. target.x = 325
  48. target.y = 68
  49. target.z = -744
  50.  
  51. -- for k,v in pairs(tmpLasers) do
  52.     -- v.emitBeam(target.x - v.lx, target.y - v.ly, target.z - v.lz)
  53.     -- sleep(0.2)
  54. -- end
  55.  
  56. while true do
  57.     --energy check
  58.     local bool ok = true
  59.     for k,v in pairs(tmpLasers) do
  60.         if (v.getEnergyStatus() < 1000000) then
  61.             print("Laser at " ..v.lx .. "; " .. v.ly .. "; " .. v.lz.. "; has insufficient energy, waiting...")
  62.             ok = false
  63.             sleep(1)
  64.             break
  65.         end
  66.         sleep(0.2)
  67.     end
  68.    
  69.     if (ok) then
  70.         print("FIRING")
  71.         for k,v in pairs(lasers.A) do
  72.             v.emitBeam(lasers.Amain.lx - v.lx, lasers.Amain.ly - v.ly, lasers.Amain.lz - v.lz)
  73.         end
  74.         for k,v in pairs(lasers.B) do
  75.             v.emitBeam(lasers.Bmain.lx - v.lx, lasers.Bmain.ly - v.ly, lasers.Bmain.lz - v.lz)
  76.         end
  77.         for k,v in pairs(lasers.C) do
  78.             v.emitBeam(lasers.Cmain.lx - v.lx, lasers.Cmain.ly - v.ly, lasers.Cmain.lz - v.lz)
  79.         end
  80.         for k,v in pairs(lasers.D) do
  81.             v.emitBeam(lasers.Dmain.lx - v.lx, lasers.Dmain.ly - v.ly, lasers.Dmain.lz - v.lz)
  82.         end
  83.  
  84.         sleep(0.05)
  85.  
  86.         lasers.Amain.emitBeam(target.x - lasers.Amain.lx, target.y - lasers.Amain.ly, target.z - lasers.Amain.lz)
  87.         lasers.Bmain.emitBeam(target.x - lasers.Bmain.lx, target.y - lasers.Bmain.ly, target.z - lasers.Bmain.lz)
  88.         lasers.Cmain.emitBeam(target.x - lasers.Cmain.lx, target.y - lasers.Cmain.ly, target.z - lasers.Cmain.lz)
  89.         lasers.Dmain.emitBeam(target.x - lasers.Dmain.lx, target.y - lasers.Dmain.ly, target.z - lasers.Dmain.lz)
  90.  
  91.         print("Waiting 10 seconds to recharge")
  92.         sleep(10)
  93.     end
  94. end
  95.  
  96.  
  97.  
  98.  
  99.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement