Advertisement
jaklsfjlsak

立场采矿实验

Jul 11th, 2023 (edited)
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. --- detects if there even is a force field attached
  2. local shield = peripheral.find("warpdriveForceFieldProjector")
  3.  
  4. if not shield then
  5.     print("No Force Field Projector Connected.")
  6. end
  7.  
  8. if shield.isInterfaced() == false then
  9.     print("No Computer Interface Upgrade Installed.")
  10. end
  11.  
  12. local _, upgrades = shield.getUpgrades()
  13. ---
  14.  
  15. --- this function is really janky but I don't want to make it better
  16. function getRange()
  17.     if upgrades:match("1/4 x Range") then
  18.         return 1
  19.     elseif upgrades:match("2/4 x Range") then
  20.         return 2
  21.     elseif upgrades:match("3/4 x Range") then
  22.         return 3
  23.     elseif upgrades:match("4/4 x Range") then
  24.         return 4
  25.     elseif upgrades:match("0/4 x Range") then
  26.         return 0
  27.     end
  28. end
  29.  
  30. Size = getRange() * 16
  31.  
  32. function getTranslation()
  33.     if upgrades:match("1/1 x Translation") then
  34.         return true
  35.         elseif upgrades:match("0/1 x Translation") then
  36.         print("No Translation Upgrade Installed.")
  37.     end
  38. end
  39.  
  40. ---
  41.  
  42.  
  43.  
  44.  
  45. function position()
  46.    
  47.  
  48. local laser = peripheral.find("warpdriveLaserCamera")
  49. -- Sets the frequency of the laser to 1420
  50. laser.beamFrequency(1420)
  51.     while true do
  52.   -- Waits for a "laserScanning" event
  53.   os.pullEvent("laserScanning")
  54.         local type, lx, ly, lz, block = laser.getScanResult()
  55.         local fx, fy, fz = shield.getLocalPosition()
  56.            
  57.             shield.translation(lx-fx, ly-fy, lz-fz)
  58.         print("Shield has been adjusted accordingly.")
  59.  
  60.     end
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement