Advertisement
Alex1979

sensordoor

Apr 17th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. local s = sensor.wrap("top")
  3. local monitor_ID = 2
  4. local xMax_mon, yMax_mon = 1, 1
  5. local name = ""
  6. local gamer = " Guest"
  7. text_scale = 2
  8.  
  9. function clearScreen(x,y)
  10. term.clear()
  11. term.setCursorPos(x,y)
  12. end
  13.  
  14.  
  15.  
  16. function getPlayers()
  17. while true do
  18. local tg = s.getTargets()
  19. local tab={}
  20. for name, det in pairs(tg) do
  21. if string.find(det.RawName,"player") then
  22. table.insert(tab,det)
  23. end
  24. print(name," ",os.time())
  25. timer = 0
  26. gamer = name
  27. end
  28. end
  29. end
  30.  
  31.  
  32. function MonitorSet()
  33. m = peripheral.wrap("monitor_"..monitor_ID)
  34. if not m.isColor() then
  35. clearScreen(1,1)
  36. error("Golden monitor not found!") -- монитор не золотой.
  37. end
  38. m.setTextColor(colors.lime)
  39. xMax_mon, yMax_mon = m.getSize()
  40.  
  41. end
  42.  
  43.  
  44. function PrintCenterMon(str)
  45. local xPos_mon, yPos_mon = m.getCursorPos()
  46. str_long = #str
  47. m.setCursorPos((xMax_mon/2-str_long/2)+1,yPos_mon)
  48. m.write(str)
  49. m.setCursorPos(1,yPos_mon+1)
  50. end
  51.  
  52. function main()
  53. timer = 0
  54. m.setTextScale(text_scale)
  55. xMax_mon = xMax_mon*(1/text_scale)
  56. yMax_mon = yMax_mon*(1/text_scale)
  57.  
  58.  
  59.  
  60. while true do
  61. sleep(1)
  62. timer = timer + 1
  63. if timer > 5 then
  64. rs.setOutput("front",true)
  65. m.clear()
  66. m.setCursorPos(1, 4)
  67. PrintCenterMon("1Ridav's Hi-Tech server")
  68. PrintCenterMon("BANK COMPUTERCRAFT. AlexCC (C)")
  69. else
  70. rs.setOutput("front",false)
  71. m.clear()
  72. m.setCursorPos(1, 3)
  73. PrintCenterMon("1Ridav's Hi-Tech server")
  74. PrintCenterMon("Dear "..gamer.."!")
  75. PrintCenterMon("WELCOM MAINCRAFT BANK.")
  76. PrintCenterMon("COMPUTERCRAFT. AlexCC (C)")
  77. PrintCenterMon("http://computercraft.ru")
  78. PrintCenterMon("")
  79. PrintCenterMon("<2014>")
  80. end
  81. if timer > 10 then timer = 9 end
  82. end
  83. end
  84. MonitorSet()
  85. parallel.waitForAll(main, getPlayers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement