Advertisement
Fews

Nuclear Reactor

Sep 16th, 2019 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. local durasi = 60
  2. local interval = 10
  3. local cooling = 10
  4. local jalan = false
  5.  
  6. function start()
  7. local drs = durasi
  8. local temp =0
  9. jalan = true
  10. redstone.setOutput("back",true)
  11. while drs > 0 do
  12. term.clear()
  13. term.setCursorPos(1,1)
  14. term.write("Sisa Waktu")
  15. term.setCursorPos(1,2)
  16. local pbar = drs/durasi *51
  17. term.setBackgroundColor(colors.green)
  18. for i=1,51 do
  19. if i>pbar then
  20. term.setBackgroundColor(colors.gray)
  21. end
  22. term.write(" ")
  23. end
  24. term.setBackgroundColor(colors.black)
  25. if jalan then
  26. if temp == interval then
  27. redstone.setOutput("back",false)
  28. jalan = not jalan
  29. temp = 0
  30. end
  31. else
  32. if temp == cooling then
  33. redstone.setOutput("back",true)
  34. jalan = not jalan
  35. temp = 0
  36. end
  37. end
  38. if jalan then
  39. print("")
  40. io.write(drs)
  41. print(" Detik")
  42. drs = drs - 1
  43. else
  44. local b = cooling - temp
  45. print("")
  46. print("Cooling Nuclear Reactor for "..tostring(b).." s")
  47. end
  48. temp = temp + 1
  49. sleep(1)
  50. end
  51. end
  52.  
  53. function toggle()
  54. if jalan then
  55. redstone.setOutput("back",false)
  56. else
  57. redstone.setOutput("back",true)
  58. end
  59. jalan = not jalan
  60. end
  61.  
  62. redstone.setOutput("back",false)
  63. while true do
  64. term.clear()
  65. term.setCursorPos(1,1)
  66. term.write("Nuclear Reactor Panel")
  67. term.setCursorPos(1,2)
  68. term.setBackgroundColor(colors.blue)
  69. term.write("Durasi : ")
  70. term.setBackgroundColor(colors.red)
  71. term.write(" - ")
  72. term.setBackgroundColor(colors.gray)
  73. term.write(" ")
  74. term.write(durasi)
  75. term.write(" ")
  76. term.setBackgroundColor(colors.green)
  77. term.write(" + ")
  78. term.setBackgroundColor(colors.black)
  79. term.write(" Detik ")
  80. term.setCursorPos(1,3)
  81. term.setBackgroundColor(colors.blue)
  82. term.write("Interval : ")
  83. term.setBackgroundColor(colors.red)
  84. term.write(" - ")
  85. term.setBackgroundColor(colors.gray)
  86. term.write(" ")
  87. term.write(interval)
  88. term.write(" ")
  89. term.setBackgroundColor(colors.green)
  90. term.write(" + ")
  91. term.setBackgroundColor(colors.black)
  92. term.write(" Detik ")
  93. term.setCursorPos(1,4)
  94. term.setBackgroundColor(colors.blue)
  95. term.write("Cooling : ")
  96. term.setBackgroundColor(colors.red)
  97. term.write(" - ")
  98. term.setBackgroundColor(colors.gray)
  99. term.write(" ")
  100. term.write(cooling)
  101. term.write(" ")
  102. term.setBackgroundColor(colors.green)
  103. term.write(" + ")
  104. term.setBackgroundColor(colors.black)
  105. term.write(" Detik ")
  106. term.setCursorPos(1,6)
  107. term.setBackgroundColor(colors.green)
  108. term.write(" ")
  109. term.setBackgroundColor(colors.black)
  110. term.write(" ")
  111. term.setBackgroundColor(colors.orange)
  112. term.write(" ")
  113. term.setCursorPos(1,7)
  114. term.setBackgroundColor(colors.green)
  115. term.write(" START ")
  116. term.setBackgroundColor(colors.black)
  117. term.write(" ")
  118. term.setBackgroundColor(colors.orange)
  119. term.write(" TOOGLE ")
  120. term.setCursorPos(1,8)
  121. term.setBackgroundColor(colors.green)
  122. term.write(" ")
  123. term.setBackgroundColor(colors.black)
  124. term.write(" ")
  125. term.setBackgroundColor(colors.orange)
  126. term.write(" ")
  127. term.setBackgroundColor(colors.black)
  128.  
  129.  
  130. local event, button, x, y = os.pullEvent("mouse_click")
  131. --durasi--
  132. if x>=12 and x<=15 and y == 2 then
  133. durasi = durasi - 1
  134. elseif x>=19 and x<=21 and y == 2 then
  135. durasi = durasi + 1
  136. elseif x>=15 and x<=18 and y == 2 then
  137. term.setCursorPos(1,4)
  138. print("")
  139. io.write("Edit Durasi : ")
  140. local a = read()
  141. durasi = tonumber(a)
  142. --interval--
  143. elseif x>=12 and x<=15 and y == 3 then
  144. interval = interval - 1
  145. elseif x>=19 and x<=21 and y == 3 then
  146. interval = interval + 1
  147. elseif x>=15 and x<=18 and y == 3 then
  148. term.setCursorPos(1,4)
  149. print("")
  150. io.write("Edit Interval : ")
  151. local a = read()
  152. interval = tonumber(a)
  153. --cooling--
  154. elseif x>=12 and x<=15 and y == 4 then
  155. cooling = cooling - 1
  156. elseif x>=19 and x<=21 and y == 4 then
  157. cooling = cooling + 1
  158. elseif x>=15 and x<=18 and y == 4 then
  159. term.setCursorPos(1,4)
  160. print("")
  161. io.write("Edit Cooling : ")
  162. local a = read()
  163. cooling = tonumber(a)
  164. elseif x>=1 and x<=7 and y>=6 and y<=8 then
  165. start()
  166. elseif x>=10 and x<=17 and y>=6 and y<=8 then
  167. toggle()
  168. end
  169.  
  170. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement