Advertisement
serafim7

радар Computronics [OpenComputers]

Nov 8th, 2020 (edited)
311
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- радар Computronics by serafim
  2.  
  3. --белый список
  4. local white = {
  5.   _bongo_ = true,
  6.   HyperGelax = true,
  7.   Kamish32 = true,
  8.   murphyy = true,
  9.   pumpkin_sl = true,
  10.   serafim = true
  11. }
  12.  
  13. local com = require('component')
  14. local event = require("event")
  15. local term = require('term')
  16. local radar = com.isAvailable("radar") and com.radar or error("нет радара")
  17. local gpu = com.gpu
  18. local w,h = gpu.getViewport()
  19.  
  20. gpu.setResolution(35,15)
  21.  
  22. while true do
  23.   local pl = radar.getPlayers()
  24.   term.clear()
  25.   gpu.setForeground(0xffb600)
  26.   gpu.set(2,1, 'в зоне обнаружения радара '..#pl..' ч.')
  27.   for i = 1, #pl do
  28.     if white[pl[i].name] then
  29.       gpu.setForeground(0x00ff00)
  30.     else
  31.       gpu.setForeground(0xff0000)
  32.     end
  33.     gpu.set(2, i+1, i..'. '..pl[i].name)
  34.     gpu.set(25, i+1, ' - '..math.floor(pl[i].distance)..' м.')
  35.   end
  36.   local e = ({event.pull(5,"key_down")})[4]
  37.   if e == 29 or e == 157 then -- Ctrl Выход
  38.     gpu.setResolution(w,h)
  39.     gpu.setBackground(0x000000)
  40.     gpu.setForeground(0xFFFFFF)
  41.     os.execute("cls")
  42.     os.exit()
  43.   end
  44. end
Advertisement
RAW Paste Data Copied
Advertisement