Advertisement
Guest User

startup

a guest
Jul 30th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.85 KB | None | 0 0
  1. m = peripheral.find("monitor")
  2. modem = peripheral.wrap("right")
  3. local counter = 0
  4. function call()
  5. m.setTextColor(colors.white)
  6. modem.open(1)
  7. event,sender,reply,rf,RTurb1,distance=os.pullEvent("modem_message")
  8. modem.close(1)
  9. m.setCursorPos(20,5)
  10. m.write(comma_value(math.floor(RTurb1)).."RF/T")
  11. sleep(0)
  12. modem.open(2)
  13. event,sender,reply,rf,STurb1,distance=os.pullEvent("modem_message")
  14. modem.close(2)
  15. m.setCursorPos(20,7)
  16. m.write(comma_value(math.floor(STurb1)).."RF/T")
  17. sleep(0)
  18. modem.open(3)
  19. event,sender,reply,rf,STurb2,distance=os.pullEvent("modem_message")
  20. modem.close(3)
  21. m.setCursorPos(20,8)
  22. m.write(comma_value(math.floor(STurb2)).."RF/T")
  23. sleep(0)
  24. modem.open(4)
  25. event,sender,reply,rf,STurb3,distance=os.pullEvent("modem_message")
  26. modem.close(4)
  27. m.setCursorPos(20,9)
  28. m.write(comma_value(math.floor(STurb3)).."RF/T")
  29. sleep(0)
  30. end
  31.  
  32. local energy=0
  33. m.clear()
  34. function powermon()
  35. modem.open(1)
  36. RFener = RTurb1+STurb1+STurb2+STurb3
  37. m.setCursorPos(1,3)
  38. m.setTextColor(colors.white)
  39. m.write("RF Produced:  ")
  40. if RFener > 0 then
  41. m.setTextColor(colors.green)
  42. m.write(comma_value(math.floor(RFener)).."RF/T         ")
  43. else
  44. RFener=0
  45. m.setTextColor(colors.red)
  46. m.write("0RF/T          ")
  47. end
  48. sleep(0)
  49. modem.close(1)
  50. end
  51.  
  52. function powerpercent()
  53. modem.open(322)
  54. e,s,f,rf,mess,d=os.pullEvent("modem_message")
  55. m.setCursorPos(1,2)
  56. m.setTextColor(colors.white)
  57. m.write("Power Stored: ")
  58. if mess > 50.0 then
  59. m.setTextColor(colors.green)
  60. m.write(mess.."%                 ")
  61. else
  62. m.setTextColor(colors.red)
  63. m.write(mess.."%                 ")
  64. end
  65. sleep(0)
  66. modem.close(322)
  67. end
  68.  
  69. function powerusage()
  70. modem.open(323)
  71. e,s,f,rf,mess1,d=os.pullEvent("modem_message")
  72. m.setCursorPos(1,4)
  73. m.setTextColor(colors.white)
  74. m.write("Energy Usage:")
  75. if colors.test(redstone.getBundledInput("back"),colors.purple) == true then
  76. energy=mess1-message
  77. else
  78. energy = mess1
  79. end
  80. if energy < 0 then
  81. m.setTextColor(colors.red)
  82. else
  83. m.setTextColor(colors.green)
  84. m.write(" ")
  85. end
  86. m.write(comma_value(math.floor(energy)).."RF/T    ")
  87. modem.close(323)
  88. end
  89.  
  90. function display()
  91. m.setCursorPos(1,1)
  92. m.setTextColor(colors.white)
  93. m.write("Power Status: ")
  94. if colors.test(redstone.getBundledInput("back"),colors.white) == false
  95. then
  96. m.setTextColor(colors.green)
  97. m.write("Normal   ")
  98. else
  99. m.setTextColor(colors.red)
  100. m.write("Critical")
  101. end
  102. m.setCursorPos(1,5)
  103. m.setTextColor(colors.white)
  104. m.write("Reactor: ")
  105. if colors.test(redstone.getBundledInput("back"),colors.green) == true then
  106. m.setTextColor(colors.green)
  107. m.write("Online ")
  108. else
  109. m.setTextColor(colors.red)
  110. m.write("Offline")
  111. end
  112. m.setCursorPos(1,7)
  113. m.setTextColor(colors.white)
  114. m.write("Turbine 1: ")
  115. if colors.test(redstone.getBundledInput("back"),colors.red) == true then
  116. m.setTextColor(colors.green)
  117. m.write("Online ")
  118. else
  119. m.setTextColor(colors.red)
  120. m.write("Offline")
  121. end
  122. m.setCursorPos(1,8)
  123. m.setTextColor(colors.white)
  124. m.write("Turbine 2: ")
  125. if colors.test(redstone.getBundledInput("back"),colors.lime) == true then
  126. m.setTextColor(colors.green)
  127. m.write("Online ")
  128. else
  129. m.setTextColor(colors.red)
  130. m.write("Offline")
  131. end
  132. m.setCursorPos(1,9)
  133. m.setTextColor(colors.white)
  134. m.write("Turbine 3: ")
  135. if colors.test(redstone.getBundledInput("back"),colors.blue) == true then
  136. m.setTextColor(colors.green)
  137. m.write("Online ")
  138. else
  139. m.setTextColor(colors.red)
  140. m.write("Offline")
  141. end
  142. end
  143.  
  144. function comma_value(amount)
  145. local formatted = amount
  146. local swap = false
  147. if formatted < 0 then
  148. formatted = formatted*-1
  149. swap=true
  150. end
  151. while true do
  152. formatted, k = string.gsub(formatted,"^(%d+)(%d%d%d)",'%1,%2')
  153. if k == 0 then
  154. break
  155. end
  156. end
  157. if swap then
  158. formatted = "-"..formatted
  159. end
  160. return formatted
  161. end
  162.  
  163. function check()
  164. if counter == 30 then
  165. m.clear()
  166. counter=0
  167. end
  168. end
  169.  
  170. while true do
  171. call()
  172. powermon()
  173. display()
  174. powerpercent()
  175. powerusage()
  176. counter=counter+1
  177. check()
  178. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement