Advertisement
pepeknamornik

hzs_software

Jun 12th, 2021 (edited)
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.81 KB | None | 0 0
  1. local verze = "21.0610.R1"
  2. local anim = 0.1
  3. local w, h = term.getSize()
  4. local kabel = "bottom"
  5. local monitor = peripheral.wrap( "monitor_14" )
  6. local poplach = false
  7. local i = 0
  8. local j = 0
  9. local zavoraDelay = 0
  10.  
  11. local popbar = 0
  12. ----------------------------------------------------
  13. function ukonceni ()
  14.     error()
  15. end
  16.  
  17. function defaultvalue()
  18. adresa = ""
  19. udalost  = ""
  20. upresneni  = ""
  21. monClear()
  22. end
  23.  
  24. function start()
  25. defaultvalue()
  26. local myWindow = window.create(term.current(),w/2-11,h/2-5,25,9)
  27. myWindow.setBackgroundColor(colors.orange)
  28. myWindow.setTextColor(colors.black)
  29. myWindow.clear()
  30. myWindow.setCursorPos (8, 5)
  31. myWindow.write"HZS Software"
  32. myWindow.setCursorPos (1, 9)
  33. myWindow.write(verze)
  34. myWindow.setCursorPos (1, 1)
  35. myWindow.write"Pepek@Soft"
  36. myWindow.setCursorPos (22, 9)
  37. myWindow.write"2021"
  38. sleep(1)
  39. menu()
  40. end
  41.  -----------------------------------------------------------------------------
  42. function monitorClear(a,ud,up, id)
  43. monitor.setBackgroundColor(colors.white)
  44. monitor.setTextColor(colors.black)
  45. monitor.clear()
  46. monitor.setTextScale(2)
  47. monitor.setCursorPos(2,1) monitor.write(ud)
  48. monitor.setCursorPos(2,4) monitor.write("Ustredna: "..id)
  49. monitor.setCursorPos(2,4) monitor.write(a)
  50. monitor.setCursorPos(2,5) monitor.write(up)
  51. end
  52.  
  53. function monClear()
  54. monitor.setBackgroundColor(colors.black)
  55. monitor.clear()
  56. end
  57.  
  58. function poplachfun()  
  59.     if poplach then
  60.     popbar = 128
  61.     pozadi.setBackgroundColor(colors.red)
  62.     i = i+1
  63.     if (i==50) then i = 0 commands.exec("/tellraw @a [{\"text\":\"POZOR! POPLACH! SVOLAVANI JEDNOTEK! -425 69 264\",\"color\":\"red\"}]</color></insert>") sleep( 0.5) end
  64.     else
  65.     popbar = 0
  66.     pozadi.setBackgroundColor(colors.lightGray)
  67.     end
  68.    
  69.     pozadi.setCursorPos(w-13,4)
  70.     pozadi.write(" Poplach! ")
  71. end
  72.  
  73. function zavoryfun()
  74.        
  75.         if zavoraDelay > 0 then
  76.             zavoraDelay = zavoraDelay -1
  77.             if zavoraDelay == 0 then zavory = false end
  78.         end
  79.        
  80.     if zavory then
  81.     pozadi.setBackgroundColor(colors.red)
  82.     j = j+1
  83.     else
  84.     zavbar = 0
  85.     pozadi.setBackgroundColor(colors.lightGray)
  86.     end
  87.     pozadi.setCursorPos(w-13,6)
  88.     pozadi.write("  Zavory  ")
  89. end
  90.  
  91. function vyjezdAuta()
  92.     if (colors.test (redstone.getBundledInput(kabel), colors.lightGray)) then
  93.     commands.exec("/tellraw @a [{\"text\":\"[HZS Bostrava] Jednotka vyjela!\",\"color\":\"green\"}]</color></insert>")
  94.     if statusy then
  95.         cDir = fs.list("/zasahy/otevrene/")
  96.         pozadi.setTextColor(colors.black)
  97.         pozadi.setBackgroundColor(colors.white)
  98.         pozadi.setCursorPos(2,4)
  99.         pozadi.write("Udalosti: ")
  100.         pozadi.setCursorPos(12,4)
  101.         pozadi.write(#cDir)
  102.         for i=1, #cDir do
  103.         data = fs.open("/zasahy/otevrene/"..cDir[i], "a")
  104.         data.writeLine("Cas vyjezdu:  "..os.date())
  105.         data.close();
  106.         shell.run("move /zasahy/otevrene/"..cDir[i].." /zasahy/uzavrene/"..cDir[i])
  107.         statusy = false
  108.         end
  109.     end
  110.     defaultvalue()
  111.     pozadi.setTextColor(colors.green)
  112.     pozadi.setBackgroundColor(colors.white)
  113.     pozadi.setCursorPos(8,2)
  114.     pozadi.write"Jednotka vyjela "
  115.     pozadi.setTextColor(colors.black)
  116.     pozadi.setCursorPos(3,h-5)
  117.     pozadi.write("                                     ")
  118.     pozadi.setCursorPos(3,h-4)
  119.     pozadi.write("                                     ")
  120.     pozadi.setCursorPos(3,h-3)
  121.     pozadi.write("                                     ")
  122.     poplach = false
  123.     zavoraDelay = 100
  124.     pozadi.setCursorPos(8,2)
  125.     pozadi.write"V klidu             "
  126.     end
  127. end
  128.  
  129. function PoplachCheck()
  130.     if fs.exists("/poplach") then
  131.     local data = fs.open("/poplach", "r")
  132.     ECUD = tonumber(data.readLine())
  133.     adresa = data.readLine()
  134.     udalost = data.readLine()
  135.     upresneni = data.readLine()
  136.     idustredny = data.readLine()
  137.     data.close()
  138.     data = fs.open("/zasahy/otevrene/"..ECUD..".txt", "a")
  139.     data.writeLine("Cas poplachu: "..os.date())
  140.     data.close()
  141.     statusy = true
  142.     fs.delete ("/poplach") 
  143.     poplach = true
  144.     zavory = true
  145.     pozadi.setTextColor(colors.red)
  146.     pozadi.setBackgroundColor(colors.white)
  147.     pozadi.setCursorPos(8,2)
  148.     pozadi.write"Vyhlasen poplach"
  149.     pozadi.setTextColor(colors.black)
  150.     pozadi.setCursorPos(3,h-5)
  151.     pozadi.write(adresa)
  152.     pozadi.setCursorPos(3,h-4)
  153.     pozadi.write(udalost)
  154.     pozadi.setCursorPos(3,h-3)
  155.     pozadi.write(upresneni)
  156.     monitorClear(adresa, udalost, upresneni, idustredny)
  157.     end
  158. end
  159.  
  160. function opakovani()
  161.     PoplachCheck()
  162.     poplachfun()
  163.     zavoryfun()
  164.     if poplach then vyjezdAuta() end
  165.     red()
  166.     cas()
  167.    
  168.     if (j>=4) and (j<10) then zavbar = 4
  169.     elseif (j == 10) then j = 0
  170.     else zavbar = 0 end
  171. end
  172.  
  173. function red ()
  174. local barvy = 0
  175.  
  176. barvy = popbar + zavbar
  177.  
  178. redstone.setBundledOutput(kabel, barvy)
  179. end
  180.  
  181.  function cas()
  182.     paintutils.drawLine(1, 1, w, 1, colors.orange)
  183.     paintutils.drawPixel (w,1, colors.red)
  184.     term.setCursorPos (w,1)
  185.     term.setTextColor(colors.black)
  186.     write "*"
  187. end
  188.  
  189. function menu()
  190.     w, h = term.getSize()
  191.     cas()
  192.     pozadi = window.create(term.current(),1,2,w,h)
  193.     pozadi.setBackgroundColor(colors.white)
  194.     pozadi.setTextColor(colors.black)
  195.     pozadi.clear()
  196.     term.setBackgroundColor(colors.white)
  197.     term.setTextColor(colors.lightGray)
  198.     term.setCursorPos(1,h) write"Pepek@Soft"
  199.     pozadi.setTextColor(colors.black)
  200.     pozadi.setCursorPos(2,2)
  201.     pozadi.write"Stav: "
  202.     pozadi.setCursorPos(2,h-6)
  203.     pozadi.write"Podrobnosti: "
  204.     pozadi.setBackgroundColor(colors.lightGray)
  205.     pozadi.setCursorPos(w-13,4)
  206.     pozadi.write(" Poplach! ")
  207.     pozadi.setCursorPos(w-13,6)
  208.     pozadi.write("  Zavory  ")
  209.  
  210.     while true do
  211.         os.startTimer(1)
  212.         opakovani()
  213.        
  214.         local event, button, x, y = os.pullEvent()
  215.        
  216.         if event == "mouse_click" and x >= w-13 and x <= w and y == 5 then
  217.         poplach = not poplach
  218.         if poplach then zavory = true else zavory = false end
  219.         elseif event == "mouse_click" and x >= w-13 and x <= w and y == 7 then
  220.         zavory = not zavory
  221.         end
  222.        
  223.        
  224.         if x == w and y == 1 then
  225.             ukonceni ()
  226.         end
  227.     end
  228. end
  229.  
  230. start()
  231.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement