Advertisement
jaklsfjlsak

激光护盾技术验证

Jul 12th, 2023 (edited)
886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. local shield = peripheral.find("warpdriveForceFieldProjector")
  2. local laser = peripheral.find("warpdriveLaserCamera")
  3. -- Sets the frequency of the laser to 1420
  4. laser.beamFrequency(1420)
  5.  
  6. local _, upgrades = shield.getUpgrades()
  7. ---
  8.  
  9. --- this function is really janky but I don't want to make it better
  10. function getRange()
  11.     if upgrades:match("1/4 x Range") then
  12.         return 1
  13.     elseif upgrades:match("2/4 x Range") then
  14.         return 2
  15.     elseif upgrades:match("3/4 x Range") then
  16.         return 3
  17.     elseif upgrades:match("4/4 x Range") then
  18.         return 4
  19.     elseif upgrades:match("0/4 x Range") then
  20.         return 0
  21.     end
  22. end
  23.  
  24. Size = getRange() * 16
  25.  
  26.     while true do
  27.   -- Waits for a "laserScanning" event
  28.   os.pullEvent("laserScanning")
  29.     local type, lx, ly, lz, block = laser.getScanResult()
  30.         local fx, fy, fz = shield.getLocalPosition()
  31.     tx = (lx-fx) / Size
  32.     ty = (ly-fy) / Size
  33.     tz = (lz-fz) / Size
  34.     print(tx, ty, tz)
  35. shield.translation(tx, ty, tz)
  36. end
  37.    
  38.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement