Advertisement
balloonanimal

Big reactor controller (monitor)

Dec 30th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.99 KB | None | 0 0
  1.  
  2.  
  3. -- Remote Wireless Big Reactor Control(monitor) by Disappearer
  4. -- This program need a wireless modem,advanced computer
  5. -- and at least 4 monitors to view informations normally.
  6. -- If you have different setup than one shown on screens
  7. -- edit these four variables below.
  8.  
  9. rednet.open("right") -- side of wireless modem
  10. local mon = peripheral.wrap("top") -- side or name of monitor
  11. local dataprotocol = "data" -- data protocol
  12. local powerprotocol = "power" -- power protocol
  13. local monx ,mony = mon.getSize()
  14.  
  15. function printdata()
  16. local id, mes, pro = rednet.receive(dataprotocol)
  17. term.redirect(mon)
  18. term.clear()
  19. mon.setTextScale(0.5)
  20. term.setCursorPos(1,1)
  21. if mes == false then
  22. write("STATUS: ")
  23. mon.setBackgroundColour(colors.red)
  24. write("ERROR")
  25. mon.setBackgroundColour(colors.black)
  26. print()
  27. print()
  28. print("Something is wrong with program or reactor setup")
  29. print("Press Ctrl+T to terminate program")
  30. else
  31. write("STATUS: ")
  32. if mes.active == true then
  33. mon.setBackgroundColour(colors.lime)
  34. write("ACTIVE")
  35. elseif mes.active == false then
  36. mon.setBackgroundColour(colors.yellow)
  37. write("NOT ACTIVE")
  38. end
  39. mon.setBackgroundColour(colors.black)
  40. print()
  41. print()
  42. print("Rods Level: " .. 100-tostring(mes.rodlevel) .." %")
  43. print("Energy Production: " .. math.floor(mes.energylasttick,0) .. " RF/t")
  44. print("Energy Stored: " .. mes.energystored .. " RF")
  45. print()
  46. print("Fuel: " .. mes.fuelamount .. "/" .. mes.fuelmax .. " mB")
  47. print("Fuel Usage: " .. math.ceil(mes.fueleatlasttick*100)/100 .. " mB/t")
  48. print("Fuel Temperature: " .. math.floor(mes.fueltemp,1) .. " C")
  49. print("Fuel Reactivity: " .. math.floor(mes.fuelreact,1) .. " %")
  50. print("Waste: " .. mes.wasteamount .. " mB")
  51. print()
  52. print("Casing Temperature:" .. math.floor(mes.casingtemp,1) .. " C")
  53. print()
  54. mon.setBackgroundColour(colors.orange)
  55. write("POWER ")
  56. mon.setBackgroundColour(colors.black)
  57. write(" ")
  58. mon.setBackgroundColour(colors.gray)
  59. write(" RODS LEVEL ")
  60. print()
  61. mon.setBackgroundColour(colors.orange)
  62. write("SWITCH")
  63. mon.setBackgroundColour(colors.black)
  64. write(" ")
  65. mon.setBackgroundColour(colors.gray)
  66. write("|<")
  67. mon.setBackgroundColour(colors.black)
  68. write(" ")
  69. mon.setBackgroundColour(colors.gray)
  70. write("<<")
  71. mon.setBackgroundColour(colors.black)
  72. write(" ")
  73. mon.setBackgroundColour(colors.gray)
  74. write("<")
  75. mon.setBackgroundColour(colors.black)
  76. write(" ")
  77. mon.setBackgroundColour(colors.gray)
  78. write(">")
  79. mon.setBackgroundColour(colors.black)
  80. write(" ")
  81. mon.setBackgroundColour(colors.gray)
  82. write(">>")
  83. mon.setBackgroundColour(colors.black)
  84. write(" ")
  85. mon.setBackgroundColour(colors.gray)
  86. write(">|")
  87. mon.setBackgroundColour(colors.black)
  88.  
  89. end
  90. sleep(0.11)
  91. end
  92.  
  93.  
  94. function sendpower()
  95.  
  96. local event, par1, tx, ty = os.pullEvent()
  97. if event == "monitor_touch" then
  98.  
  99. if tx == 8 or tx == 9 and ty == 16 then
  100. rednet.broadcast("zero",powerprotocol)
  101.  
  102. elseif tx == 11 or tx == 12 and ty == 16 then
  103. rednet.broadcast("minusten",powerprotocol)
  104.  
  105.  
  106. elseif tx == 14 and ty == 16 then
  107. rednet.broadcast("minus",powerprotocol)
  108.  
  109.  
  110. elseif tx == 17 and ty == 16 then
  111. rednet.broadcast("plus",powerprotocol)
  112.  
  113.  
  114. elseif tx == 19 or tx == 20 and ty == 16 then
  115. rednet.broadcast("plusten",powerprotocol)
  116.  
  117. elseif tx == 22 or tx == 24 and ty == 16 then
  118. rednet.broadcast("sto",powerprotocol)
  119.  
  120. elseif tx<7 and ty == 15 or tx<7 and ty == 16 then
  121. rednet.broadcast("poweron",powerprotocol)
  122. end
  123. end
  124. end
  125.  
  126. while true do
  127. parallel.waitForAny(printdata,sendpower)
  128. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement