Guest User

door.lua

a guest
Apr 14th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. --Open door if radar see player
  2. --Beelzebub dreamfinity Technocracy for City17
  3. ----[ Библиотеки ]----
  4. local component = require("component")
  5. local sides = require("sides")
  6. local term = require("term")
  7. ----[ Константы ]----
  8. local gpu = component.gpu
  9. ----[ Код ]----
  10. --gpu.setResolution(35,10)
  11. gpu.setResolution(140,40)
  12. -- Цвета --
  13. color = {
  14.   green = 0x00ff00,
  15.   yellow = 0xffb600,
  16.   red = 0xff0000
  17. }
  18. -- Белый список ---
  19. white = {
  20.   Beelzebub = true,
  21.   rrr_game = true,
  22.   AlexeyRepin = true,
  23.   RedMaster12341 = true
  24. }
  25.  
  26. while true do
  27.   local sensor = component.radar.getPlayers()
  28.   for i = 1, #sensor do
  29.     if white[sensor[i].name] then
  30.     if sensor[i].distance <= 4 then
  31.        component.redstone.setOutput(sides.up,0)
  32.        gpu.setForeground(color.green)
  33.     else
  34.       component.redstone.setOutput(sides.up,15)
  35.       gpu.setForeground(color.red)
  36.     end
  37.       term.clear()
  38.       print(sensor[i].name)
  39.       print(sensor[i].distance)
  40.     end
  41.   end
  42.    
  43. end
Advertisement
Add Comment
Please, Sign In to add comment