jaklsfjlsak

激光扫描发射器 三维定位

Apr 20th, 2025
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local lasers = peripheral.getNames()
  2.  
  3. rednet.open("top")
  4.  
  5. for i = #lasers, 1, -1 do
  6.     if peripheral.getType(lasers[i]) ~= "warpdriveLaserCamera" then
  7.         table.remove(lasers, i)
  8.     else
  9.         peripheral.wrap(lasers[i]).beamFrequency(1420)
  10.     end
  11. end
  12.  
  13. print("Emit Scanning Laser to Target a Block")
  14.  
  15. while true do
  16.     local event, laserName, lx, ly, lz, block, _, _, _, type, metadata, resistance = os.pullEvent()
  17.  
  18.     if event == "laserScanning" then
  19.         -- Convert the laser scanning coordinates to numbers and store them
  20.         local lastLx = tonumber(lx)
  21.         local lastLy = tonumber(ly)
  22.         local lastLz = tonumber(lz)
  23.        
  24.        
  25.         print("Laser target: X:" .. lastLx .. " Y:" .. lastLy .. " Z:" .. lastLz)
  26.  
  27.             -- Package the coordinates into a table (you can also send a formatted string)
  28.             local data = { x = lastLx, y = lastLy, z = lastLz }
  29.            
  30.             -- Broadcast the coordinates using a custom protocol ("coordBroadcast")
  31.             rednet.broadcast(data, "3DOffsetBroadcast")
  32. end
  33. end
  34.  
Advertisement
Add Comment
Please, Sign In to add comment