pepeknamornik

nuclear app

Jun 20th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.45 KB | None | 0 0
  1. local kabel = "back"
  2. local myTimer = os.startTimer(1)
  3. local savedata = 0
  4. local cooler1_click = 0
  5. local cooler2_click = 0
  6. local reactor_start = false
  7. local cooler1 = true
  8. local cooler2 = false
  9.  
  10. local nastaveni={barva=colors.blue}
  11. local f=fs.open("/C/system/.core/colors","r")
  12. local cnt=f.readAll()
  13. f.close()
  14. local nastaveni=textutils.unserialize(cnt)
  15.      
  16. local f=fs.open("/C/system/.core/textcol","r")
  17. local tnt=f.readAll()
  18. f.close()
  19. local text=textutils.unserialize(tnt)
  20.  
  21. local function prc(text, y)
  22.   local w = term.getSize()
  23.   local _, cy = term.getCursorPos()
  24.   term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  25.   write(text)
  26. end
  27.  
  28. local f=fs.open("/C/system/RAM/user","r")
  29. user=f.readLine()
  30. f.close()
  31.  
  32.  
  33.  
  34. function start ()
  35.     term.setBackgroundColor(colors.white)
  36.     term.setTextColor(colors.black)
  37.     term.clear ()
  38.         if not fs.exists ("/C/Programs/PepekSoft/nuclear.nft") then
  39.         shell.run("pastebin get 4k2p5N4w /C/Programs/PepekSoft/nuclear.nft")
  40.         end
  41.     local image = paintutils.loadImage("/C/Programs/PepekSoft/nuclear.nft")
  42.     paintutils.drawImage(image, 18, 4)
  43.     term.setBackgroundColor(colors.white)
  44.     prc ("Nuclear reactor control", 16)
  45.     sleep (1)
  46. loaddata()
  47. recovery()
  48. nuclear()
  49. end
  50.  
  51. function loaddata()
  52.     if  fs.exists("/C/Programs/Pepeksoft/NuclearTemp/status.cfg") then
  53.     data = fs.open("/C/Programs/Pepeksoft/NuclearTemp/status.cfg","r")
  54.     var1 = data.readLine()
  55.     var2 = data.readLine()
  56.     var3 = data.readLine()
  57.     data.close()
  58.     end
  59. end
  60.  
  61. function recovery()
  62.     if var2 == "true" and var3 == "true" and var1 == "true" then
  63.     redstone.setBundledOutput(kabel, colors.lime+colors.red+colors.yellow+colors.white)
  64.     elseif var2 == "true" and var3 == "true" then
  65.     redstone.setBundledOutput(kabel, colors.lime+colors.red)
  66.     elseif var2 == "true" and var3 == "false" then
  67.     redstone.setBundledOutput(kabel, colors.red)
  68.     elseif var2 == "false" and var3 == "true" then
  69.     redstone.setBundledOutput(kabel, colors.lime)
  70.     end
  71. end
  72.  
  73. function redstoneset()
  74. term.setCursorPos(1,1)
  75.         write "rs-set"
  76. if cooler1_click == 1 then
  77.     cooler1_click = 0
  78.         if cooler2 == true then
  79.         redstone.setBundledOutput(kabel, colors.lime+colors.red)
  80.         term.setCursorPos(1,2)
  81.         write "c1/1/1"
  82.         else
  83.         redstone.setBundledOutput(kabel, colors.red)
  84.         term.setCursorPos(1,2)
  85.         write "c1/1/2"
  86.         end
  87. elseif cooler1_click == 2 then
  88.     cooler1_click = 0
  89.         if cooler2 == true then
  90.         redstone.setBundledOutput(kabel, colors.lime)
  91.         term.setCursorPos(1,2)
  92.         write "c1/2/1"
  93.         else
  94.         redstone.setBundledOutput(kabel, 0)
  95.         term.setCursorPos(1,2)
  96.         write "c2/2/1"
  97.         end
  98. elseif cooler2_click == 1 then
  99.     cooler2_click = 0
  100.         if cooler1 == true then
  101.         redstone.setBundledOutput(kabel, colors.lime+colors.red)
  102.         term.setCursorPos(1,2)
  103.         write "c2/1/1"
  104.         else
  105.         redstone.setBundledOutput(kabel, colors.lime)
  106.         term.setCursorPos(1,2)
  107.         write "c2/1/2"
  108.         end
  109. elseif cooler2_click == 2 then
  110.     cooler2_click = 0
  111.         if cooler1 == true then
  112.         redstone.setBundledOutput(kabel, colors.red)
  113.         term.setCursorPos(1,2)
  114.         write "c2/2/1"
  115.         else
  116.         redstone.setBundledOutput(kabel, 0)
  117.         term.setCursorPos(1,2)
  118.         write "c2/2/1"
  119.         end
  120. end
  121. end
  122.  
  123. function reactorset()
  124. term.setCursorPos(1,1)
  125. write "rc-set"
  126.  
  127.     if reactor_click == 1 and cooler1 == true and cooler2 == true then
  128.     redstone.setBundledOutput(kabel, colors.lime+colors.red+colors.white)
  129.     term.setCursorPos(1,2)
  130.             write "rc-t  "
  131.     elseif reactor_click == 2 then
  132.     redstone.setBundledOutput(kabel, colors.lime+colors.red)
  133.     term.setCursorPos(1,2)
  134.             write "rc-f  "
  135.     else
  136.     term.setCursorPos(1,2)
  137.             write "ERROR "
  138.     end
  139. end
  140.  
  141. function nuclear()
  142. while true do
  143. local f=fs.open("/C/Programs/Pepeksoft/NuclearTemp/status.cfg","w")
  144. f.writeLine(reactor_start)
  145. f.writeLine(cooler1)
  146. f.writeLine(cooler2)
  147. f.close()
  148.  
  149. energy_read = redstone.testBundledInput(kabel, colors.lightBlue)
  150. cooler1 = redstone.testBundledInput(kabel, colors.red)
  151. cooler2 = redstone.testBundledInput(kabel, colors.lime)
  152. reactor_start = redstone.testBundledInput(kabel, colors.white)
  153.  
  154. x,y = term.getSize()
  155. os.startTimer(0.5)
  156. term.setBackgroundColor(colors.white)
  157. term.setTextColor(colors.black)
  158. term.clear()
  159. paintutils.drawLine(1, 19, 51, 19, colors.lightGray)
  160. term.setCursorPos(46,19)
  161. write(textutils.formatTime(os.time(), true))
  162. term.setBackgroundColor(colors.gray)
  163. term.setCursorPos(1,19)
  164. write"MENU"
  165. term.setBackgroundColor(colors.white)
  166. term.setTextColor(colors.green)
  167. prc (" Nuclear control", 1)
  168. term.setTextColor(colors.black)
  169. term.setCursorPos(35,3)
  170. write ("Reactor : ")
  171. term.setCursorPos(35,4)
  172. write "Cooler 1: "
  173. term.setCursorPos(35,5)
  174. write "Cooler 2: "
  175. term.setCursorPos(35,7)
  176. write "Energy  : "
  177.  
  178. term.setCursorPos(45,3)
  179.     if reactor_start == true then
  180.     term.setTextColor(colors.green)
  181.     reactor_status = "Running"
  182.     else
  183.     term.setTextColor(colors.red)
  184.     reactor_status = "Stoped"
  185.     end
  186. write (reactor_status)
  187.  
  188. term.setCursorPos(45,4)
  189.     if cooler1 == true then
  190.     term.setTextColor(colors.green)
  191.     cooler1_status = "Running"
  192.     else
  193.     term.setTextColor(colors.red)
  194.     cooler1_status = "Stoped"
  195.     end
  196. write (cooler1_status)
  197.  
  198. term.setCursorPos(45,5)
  199.     if cooler2 == true then
  200.     term.setTextColor(colors.green)
  201.     cooler2_status = "Running"
  202.     else
  203.     term.setTextColor(colors.red)
  204.     cooler2_status = "Stoped"
  205.     end
  206. write (cooler2_status)
  207.  
  208. term.setCursorPos(45,7)
  209.     if energy_read == true then
  210.     term.setTextColor(colors.green)
  211.     energy_status = "Running"
  212.     else
  213.     term.setTextColor(colors.red)
  214.     energy_status = "Stoped"
  215.     end
  216. write (energy_status)
  217.  
  218. term.setBackgroundColor(colors.lightGray)
  219. term.setTextColor(colors.black)
  220. term.setCursorPos(5,4)
  221. write " Cooler  1 "
  222. term.setCursorPos(5,6)
  223. write " Cooler  2 "
  224. term.setCursorPos(5,8)
  225. write "  Reactor  "
  226. term.setCursorPos(5,9)
  227.     if reactor_start == true then
  228.     write "    STOP   "
  229.     else
  230.     write "   START   "
  231.     end
  232.  
  233.  
  234.  
  235.  
  236.  
  237. event, param1, x,y = os.pullEvent()
  238.     if event == "mouse_click" and x >= 5 and x <= 16 and y == 4 then
  239.         term.setBackgroundColor(colors.gray)
  240.         term.setTextColor(colors.white)
  241.         term.setCursorPos(5,4)
  242.         write " Cooler  1 "
  243.             if cooler1 == true then
  244.             cooler1_click = 2
  245.             else
  246.             cooler1_click = 1
  247.             end
  248.             redstoneset()
  249.         sleep (0.5)
  250.     elseif event == "mouse_click" and x >= 5 and x <= 16 and y == 6 then
  251.         term.setBackgroundColor(colors.gray)
  252.         term.setTextColor(colors.white)
  253.         term.setCursorPos(5,6)
  254.         write " Cooler  2 "
  255.         if cooler2 == true then
  256.             cooler2_click = 2
  257.             else
  258.             cooler2_click = 1
  259.             end
  260.             redstoneset()
  261.         sleep (0.5)
  262.     elseif event == "mouse_click" and x >= 5 and x <= 16 and y >= 8 and y <= 9 then
  263.         term.setBackgroundColor(colors.gray)
  264.         term.setTextColor(colors.white)
  265.         term.setCursorPos(5,8)
  266.         write "  Reactor  "
  267.         term.setCursorPos(5,9)
  268.             if reactor_start == true then
  269.             write "    STOP   "
  270.             else
  271.             write "   START   "
  272.             end
  273.            
  274.         if reactor_start == true then
  275.             reactor_click = 2
  276.             else
  277.             reactor_click = 1
  278.             end
  279.         reactorset()
  280.            
  281.         sleep (0.5)
  282.     elseif event == "mouse_click" and x >= 1 and x <= 5 and y == 19 then
  283.         term.setTextColor(colors.white)
  284.         term.setCursorPos(1,19)
  285.         write "MENU"
  286.         local myWindow = window.create(term.current(),2,17,8,19)
  287.         myWindow.setBackgroundColor(colors.lightGray)
  288.         myWindow.clear()
  289.         term.setBackgroundColor(colors.gray)
  290.         term.setCursorPos(2,15)
  291.         write "          "
  292.         term.setCursorPos(2,16)
  293.         write " Desktop  "
  294.         term.setCursorPos(2,17)
  295.         write " Sleep    "
  296.         term.setCursorPos(2,18)
  297.         write " Restart  "
  298.         term.setCursorPos(2,19)
  299.         write " Shutdown "
  300.        
  301.             while true do
  302.             local event, button, x, y = os.pullEvent("mouse_click")
  303.             xy = x..","..y
  304.    
  305.                 if (x >= 1 and x <= 10 and y == 17) and (button == 1 or button == 2)then
  306.                 sleep ()
  307.                 elseif (x >= 1 and x <= 10 and y == 18) and (button == 1 or button == 2)then
  308.                 restart ()
  309.                 elseif (x >= 1 and x <= 10 and y == 19) and (button == 1 or button == 2)then
  310.                 vypnout ()
  311.                 elseif (x >= 1 and x <= 10 and y == 16) and (button == 1 or button == 2)then
  312.                 os.exit()
  313.                 else
  314.                 nuclear()
  315.                 end
  316.             end          
  317.         return
  318.         false -- Here is the important part.
  319.         end
  320.     end
  321. end
  322.  
  323. function spanek ()
  324.     term.setBackgroundColor(colors.lightGray)
  325.     term.clear()
  326.     sleep (0.1)
  327.     term.setBackgroundColor(colors.gray)
  328.     term.clear()
  329.     sleep (0.1)
  330.     term.setBackgroundColor(colors.black)
  331.     term.setTextColor(colors.black)
  332.     term.clear()
  333.    
  334.     while true do
  335.           local event, button, xPos, yPos = os.pullEvent("mouse_click")
  336.           nuclear ()
  337.     end
  338. end
  339.  
  340. start()
Add Comment
Please, Sign In to add comment