Advertisement
marko_rus

main

Jun 11th, 2018
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.05 KB | None | 0 0
  1. local image = require("image")
  2. local com =require("component")
  3. local gpu =com.gpu
  4. local pc =require("computer")
  5. modem =com.modem
  6. local GUI = require("GUI")
  7. local event = require("event")
  8. local term =require("term")
  9. local w, h = gpu.getResolution()
  10. gpu.setBackground(0xFFFFFF)
  11. local distance,olddistance,msg,oldmsg
  12. local history = {}
  13. local n = 1
  14. local b = 2
  15. local scrl = 1
  16. local txt =""
  17. local name =""
  18. local contacts = {"1032677a-453d-4059-ba3e-c005761b3e55","marko_rus","8199a046-62bf-4274-9eb7-3adf74ae2f93","marko_rus2"}
  19.  
  20. gpu.fill(1, 1, w, h, " ")
  21. image.draw(35, 10, image.load("/tpchat/bin/pic/logofinal.pic"))
  22. gpu.setBackground(0xFFFFFF)
  23. gpu.setForeground(0x00FFFF)
  24. print("    Team Poligon Chat pre-release v0.214")
  25. print("открытие порта...")
  26. modem.open(142)
  27. print("инициализация")
  28.  
  29. local mainContainer = GUI.fullScreenContainer()
  30. mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0x2D2D2D))
  31.  
  32. mainContainer:addChild(GUI.input(2, 2, 30, 3, 0xEEEEEE, 0x555555, 0x999999, 0xFFFFFF, 0x2D2D2D, "Hello world", "Placeholder text")).onInputFinished = function()
  33.     GUI.alert("Input finished!")
  34. end
  35.  
  36. os.sleep(2,5)
  37. print("       ну чё, стартанём?")
  38. os.sleep(1)
  39. gpu.setBackground(0x222222)
  40. gpu.fill(1,1,w,h," ")
  41. term.setCursor(1,1)
  42.  
  43. pc.beep(1000)
  44. while true do
  45.  
  46. term.setCursor(1,1)
  47. term.clearLine()
  48. --print("Введите сообщение: " ..txt)
  49.  
  50. mainContainer: drawOnScreen ( true )
  51.  mainContainer: startEventHandling (0,1)
  52. print("123")
  53. _,_,adr,_,distance,msg = event.pull(0,1 ,"modem_message")
  54.  
  55. if msg and distance then
  56. pc.beep(500)
  57. while contacts[b] do
  58. if contacts[b-1] == adr then
  59. name = contacts[b]
  60. break
  61. end
  62. b =b+2
  63. end
  64.  
  65.  
  66. b = 2
  67.  
  68. history[n] = name ..": " ..msg .." (в ".. math.ceil(distance) .."м от вас )"
  69. term.clear()
  70. ---end
  71.  
  72. term.setCursor(1,30)
  73. for i=1, 21 do
  74. if history[n-21+i] then
  75. print(history[n-21+i])
  76. end
  77. end
  78.  
  79. ---print(adr ..": " ..history[n] .." (в ".. math.ceil(distance) .."м от вас )")
  80. n = n+1
  81.  end
  82.  
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement