Advertisement
MeXaN1cK

2

Apr 3rd, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.24 KB | None | 0 0
  1. local cmp = require("component")
  2. local gpu = cmp.gpu
  3. local term = require("term")
  4. local gui = require("zth_gui")
  5. local event = require("event")
  6. local isRunning = true
  7. local sides = require("sides")
  8.  keyboard=require("keyboard")
  9. gpu.bind(cmp.get("160"))
  10. term.clear()
  11.  
  12. TabReac1={Reactor=cmp.proxy(cmp.get("597")), RedBlock=cmp.proxy(cmp.get("b33"))}
  13. TabReac2={Reactor=cmp.proxy(cmp.get("0c6")), RedBlock=cmp.proxy(cmp.get("c6a"))}
  14. TabReac3={Reactor=cmp.proxy(cmp.get("1da")), RedBlock=cmp.proxy(cmp.get("ec8"))}
  15. TabReac4={Reactor=cmp.proxy(cmp.get("907")), RedBlock=cmp.proxy(cmp.get("d07"))}
  16. TabReac5={Reactor=cmp.proxy(cmp.get("b08")), RedBlock=cmp.proxy(cmp.get("d44"))}
  17. TabComponent={[1]=TabReac1, [2]=TabReac2, [3]=TabReac3, [4]=TabReac4, [5]=TabReac5}
  18. maxTemp=1000
  19.  
  20. function sB1(newState1)
  21.   local rs = TabComponent[1].RedBlock--cmp.proxy(cmp.get("b33"))
  22.   if newState1 == "active" then
  23.     rs.setOutput(sides.up, 15)
  24.   else
  25.     rs.setOutput(sides.up, 0)
  26.   end
  27. end
  28. function sB2(newState2)
  29.   local rs = TabComponent[2].RedBlock--cmp.proxy(cmp.get("c6a"))
  30.   if newState2 == "active" then
  31.     rs.setOutput(sides.up, 15)
  32.   else
  33.     rs.setOutput(sides.up, 0)
  34.   end
  35. end
  36. function sB3(newState3)
  37.   local rs = TabComponent[3].RedBlock--cmp.proxy(cmp.get("ec8"))
  38.   if newState3 == "active" then
  39.     rs.setOutput(sides.up, 15)
  40.   else
  41.     rs.setOutput(sides.up, 0)
  42.   end
  43. end
  44. function sB4(newState4)
  45.   local rs = TabComponent[4].RedBlock--cmp.proxy(cmp.get("d07"))
  46.   if newState4 == "active" then
  47.     rs.setOutput(sides.up, 15)
  48.   else
  49.     rs.setOutput(sides.up, 0)
  50.   end
  51. end
  52. function sB5(newState5)
  53.   local rs = TabComponent[5].RedBlock--cmp.proxy(cmp.get("d44"))
  54.   if newState5 == "active" then
  55.     rs.setOutput(sides.up, 15)
  56.   else
  57.     rs.setOutput(sides.up, 0)
  58.   end
  59. end
  60. function exitProgram()
  61.   term.clear()
  62.   isRunning = false
  63.   term.clear()
  64. end
  65.  
  66. function callback(evID, ...)
  67.  
  68.   if evID then
  69.     gui.callbackTouch(...)
  70.   end
  71. end
  72.  
  73. term.clear()
  74. gui.addButton(1, 20, "1", 0xFF0000, 0x00FF00, true, sB1)
  75. gui.addButton(10, 20, "2", 0xFF0000, 0x00FF00, true, sB2)
  76. gui.addButton(20, 20, "3", 0xFF0000, 0x00FF00, true, sB3)
  77. gui.addButton(30, 20, "4", 0xFF0000, 0x00FF00, true, sB4)
  78. gui.addButton(40, 20, "5", 0xFF0000, 0x00FF00, true, sB5)
  79. gui.addButton(71, 20, "Выход", 0xFF0000, 0xFF8888, false, exitProgram)
  80.  
  81. event.listen("touch", callback)
  82.  
  83. while isRunning do
  84.   gui.drawUI()
  85.   os.sleep(0.5)
  86.   term.setCursor(1,1)
  87.   gpu.setResolution(80,25)
  88.   gpu.setBackground(0x0000CD)
  89.   print("Реактор      Температура    eU/t       Состояние")
  90.   gpu.setBackground(0x0000FF)
  91.   if keyboard.isKeyDown('r') then computer.shutdown(true) end
  92.   for key=1,5 do
  93.     str = "Включен "  gpu.setBackground(0x00FF00)
  94.     if TabComponent[key].RedBlock.getOutput(sides.up) == 0 then str = "Выключен" gpu.setBackground(0xFF0000) end
  95. --    print('     №'..key..,string.format(  '       ',TabComponent[key].Reactor.getHeat(),'    ',TabComponent[key].Reactor.getReactorEUOutput(), str)--,TestReac(key))
  96.         local r = TabComponent[key].Reactor
  97.       print(string.format("№%d          %05.2f    %05.3f      %s", key, r.getHeat(), r.getReactorEUOutput(), str))
  98.   end
  99. end
  100. term.clear()
  101. gpu.bind(cmp.get("e04"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement