DRlVER124

Radar

Aug 26th, 2018
1,007
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. local term = require('term')
  2. local com = require('component')
  3. local gpu = com.gpu
  4. local GUI = require("GUI")
  5. floor = math.floor
  6.  
  7. gpu.setBackground(0x000000)
  8. gpu.setForeground(0xffffff)
  9.  
  10. local w, h = gpu.getResolution()
  11. gpu.fill(1, 1, w, h, " ") -- очищаем экран
  12.  
  13. if com.isAvailable("radar") then
  14. sensor = com.radar
  15.  
  16. elseif com.isAvailable("openperipheral_sensor") then
  17. sensor = com.openperipheral_sensor
  18. else GUI.alert("Для работы программы нужен радар из мода Computronics или Sensor из аддона OpenPeripheral")
  19. return
  20. end
  21.  
  22. while true do
  23. gpu.setResolution(35,15)
  24. pl = sensor.getPlayers()
  25. term.clear()
  26. gpu.setForeground(0xffb600)
  27. gpu.set(2,1, 'В зоне обнаружения радара: '..#pl..' чел.')
  28. for i = 1, #pl do
  29. gpu.setForeground(0xffffff)
  30. gpu.set(2, i+1, i..'. '..pl[i].name)
  31. if com.isAvailable("radar") then
  32. gpu.set(25, i+1, ' - '..floor(pl[i].distance)..' м')
  33. end
  34. end
  35. os.sleep(3)
  36. end
Advertisement
Add Comment
Please, Sign In to add comment