Advertisement
Belzebub

Open Door if Radar see white list player.lua

Apr 14th, 2018
632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Open door if radar see player (Component Radar)
  2. --Beelzebub dreamfinity Technocracy for clan City17
  3. --Радар багаеться если в его радиусе находиться 2 или более игроков из вайт листа
  4. --Так что советую использовать прогу только в одиночку, либо переделывать под сенсор
  5. --Из OpenPhieral (но у нас на Technocracy его нету)
  6. --Чуть ранее я выкладывал программу для сенсора на моём пастебине, см там.
  7. ----[ Библиотеки ]----
  8. local component = require("component")
  9. local sides = require("sides")
  10. local term = require("term")
  11. ----[ Константы ]----
  12. local gpu = component.gpu
  13. ----[ Код ]----
  14. --gpu.setResolution(10,3)
  15. gpu.setResolution(140,40)
  16. term.clear()
  17. ---- Цвета ----
  18. color = {
  19.   green = 0x00ff00,
  20.   red = 0xff0000
  21. }
  22. ---- Белый список ----
  23. white = {
  24.   Beelzebub = true
  25. }
  26.  
  27. local function CoreScreenFix()
  28.     comp.gpu.bind(comp.screen.address,true)
  29.     buffer.setResolution(80,25)
  30. end
  31.   local antiFreezeTimer = require("event").timer(15,CoreScreenFix,math.huge)
  32.  
  33. while true do
  34.   local sensor = component.radar.getPlayers()
  35.   for i = 1, #sensor do
  36.     if white[sensor[i].name] then
  37.     if sensor[i].distance <= 4 then
  38.       name = sensor[i].name
  39.       distance = sensor[i].distance
  40.         component.redstone.setOutput(sides.up,0)
  41.         gpu.setForeground(color.green)
  42.     else
  43.       name = sensor[i].name
  44.       distance = sensor[i].distance
  45.         component.redstone.setOutput(sides.up,15)
  46.         gpu.setForeground(color.red)
  47.     end
  48.     local name2 = tostring(name)
  49.     local distance2 = tostring(distance)
  50.       gpu.set(1,2,name2)
  51.       gpu.set(1,3,distance2)
  52.     end
  53.   end
  54. os.sleep(0.005)
  55. end
  56. --В планах сделать программу на 100 процентов рабочей.
  57. --И как нибудь закостылить косяки радара дабы он адекватно работал с несколькими игроками.
  58. --Fix вывод
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement