Advertisement
pepeknamornik

Pepdroll 7 Nuclear Edition

Jun 11th, 2019
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.16 KB | None | 0 0
  1. verze = "19.0612"
  2.  
  3. local kabel = "back"
  4. local myTimer = os.startTimer(1)
  5. local savedata = 0
  6. local cooler1_click = 0
  7. local cooler2_click = 0
  8. local reactor_start = false
  9. local cooler1 = true
  10. local cooler2 = false
  11.  
  12. local function prc(text, y)
  13.   local w = term.getSize()
  14.   local _, cy = term.getCursorPos()
  15.   term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  16.   write(text)
  17. end
  18.  
  19. function start ()
  20. term.setBackgroundColor(colors.white)
  21. term.setTextColor(colors.black)
  22. term.clear()
  23. term.setBackgroundColor(colors.white)
  24. term.setTextColor(colors.blue)
  25. term.setCursorPos(20,18)
  26. print"  Pepek"
  27. term.setCursorPos(28,18)
  28. print"Soft  "
  29. term.setCursorPos(27,18)
  30. term.setTextColor(colors.lime)
  31. print"@"
  32. term.setCursorPos(5, 14)
  33. print ("Build "..verze)
  34. term.setBackgroundColor(colors.white)
  35. term.setTextColor(colors.black)
  36. term.setCursorPos(16,7)
  37. prc "Pepdroll 7 Nuclear Edition"
  38. term.setCursorPos(14,9)
  39. term.setBackgroundColor(colors.green)
  40. textutils.slowPrint "                        "
  41. loaddata()
  42. term.setCursorPos(14,9)
  43. term.setBackgroundColor(colors.lightGray)
  44. textutils.slowPrint "                        "
  45. recovery()
  46. term.setCursorPos(14,10)
  47. term.setBackgroundColor(colors.white)
  48. term.setTextColor(colors.white)
  49. shell.run("pastebin get eRHQs2wN /online")
  50. term.setCursorPos(14,9)
  51. term.setBackgroundColor(colors.green)
  52. textutils.slowPrint "          "
  53. nuclear()
  54. end
  55.  
  56. function desktop()
  57. term.setBackgroundColor(colors.cyan)
  58. term.setTextColor(colors.black)
  59. term.clear()
  60. paintutils.drawLine(1, 19, 51, 19, colors.lightGray)
  61. term.setCursorPos(1,19)
  62. term.setBackgroundColor(colors.gray)
  63. write"Power"
  64.  
  65.     while true do
  66.     local event, button, x, y = os.pullEvent("mouse_click")
  67.     xy = x..","..y
  68.  
  69.         if (x >= 1 and x <= 5 and y == 19) and (button == 1 or button == 2)then
  70.         local myWindow = window.create(term.current(),2,17,8,19)
  71.         myWindow.setBackgroundColor(colors.lightGray)
  72.         myWindow.clear()
  73.         term.setBackgroundColor(colors.gray)
  74.         term.setCursorPos(2,17)
  75.         write " Sleep    "
  76.         term.setCursorPos(2,18)
  77.         write " Restart  "
  78.         term.setCursorPos(2,19)
  79.         write " Shutdown "
  80.        
  81.             while true do
  82.             local event, button, x, y = os.pullEvent("mouse_click")
  83.             xy = x..","..y
  84.    
  85.                 if (x >= 2 and x <= 10 and y == 17) and (button == 1 or button == 2)then
  86.                 spanek ()
  87.                 elseif (x >= 2 and x <= 10 and y == 18) and (button == 1 or button == 2)then
  88.                 restart ()
  89.                 elseif (x >= 2 and x <= 10 and y == 19) and (button == 1 or button == 2)then
  90.                 vypnout ()
  91.                 else
  92.                 desktop()      
  93.                 end
  94.             end            
  95.         end
  96.     end
  97. end
  98.  
  99. function loaddata()
  100.     if  fs.exists("status.cfg") then
  101.     data = fs.open("status.cfg","r")
  102.     var1 = data.readLine()
  103.     var2 = data.readLine()
  104.     var3 = data.readLine()
  105.     data.close()
  106.     end
  107. end
  108.  
  109. function recovery()
  110.     if var2 == "true" and var3 == "true" and var1 == "true" then
  111.     redstone.setBundledOutput(kabel, colors.lime+colors.red+colors.yellow+colors.white)
  112.     elseif var2 == "true" and var3 == "true" then
  113.     redstone.setBundledOutput(kabel, colors.lime+colors.red)
  114.     elseif var2 == "true" and var3 == "false" then
  115.     redstone.setBundledOutput(kabel, colors.red)
  116.     elseif var2 == "false" and var3 == "true" then
  117.     redstone.setBundledOutput(kabel, colors.lime)
  118.     end
  119. end
  120.  
  121. function redstoneset()
  122. term.setCursorPos(1,1)
  123.         write "rs-set"
  124. if cooler1_click == 1 then
  125.     cooler1_click = 0
  126.         if cooler2 == true then
  127.         redstone.setBundledOutput(kabel, colors.lime+colors.red)
  128.         term.setCursorPos(1,2)
  129.         write "c1/1/1"
  130.         else
  131.         redstone.setBundledOutput(kabel, colors.red)
  132.         term.setCursorPos(1,2)
  133.         write "c1/1/2"
  134.         end
  135. elseif cooler1_click == 2 then
  136.     cooler1_click = 0
  137.         if cooler2 == true then
  138.         redstone.setBundledOutput(kabel, colors.lime)
  139.         term.setCursorPos(1,2)
  140.         write "c1/2/1"
  141.         else
  142.         redstone.setBundledOutput(kabel, 0)
  143.         term.setCursorPos(1,2)
  144.         write "c2/2/1"
  145.         end
  146. elseif cooler2_click == 1 then
  147.     cooler2_click = 0
  148.         if cooler1 == true then
  149.         redstone.setBundledOutput(kabel, colors.lime+colors.red)
  150.         term.setCursorPos(1,2)
  151.         write "c2/1/1"
  152.         else
  153.         redstone.setBundledOutput(kabel, colors.lime)
  154.         term.setCursorPos(1,2)
  155.         write "c2/1/2"
  156.         end
  157. elseif cooler2_click == 2 then
  158.     cooler2_click = 0
  159.         if cooler1 == true then
  160.         redstone.setBundledOutput(kabel, colors.red)
  161.         term.setCursorPos(1,2)
  162.         write "c2/2/1"
  163.         else
  164.         redstone.setBundledOutput(kabel, 0)
  165.         term.setCursorPos(1,2)
  166.         write "c2/2/1"
  167.         end
  168. end
  169. end
  170.  
  171. function reactorset()
  172. term.setCursorPos(1,1)
  173. write "rc-set"
  174.  
  175.     if reactor_click == 1 and cooler1 == true and cooler2 == true then
  176.     redstone.setBundledOutput(kabel, colors.lime+colors.red+colors.white)
  177.     term.setCursorPos(1,2)
  178.             write "rc-t  "
  179.     elseif reactor_click == 2 then
  180.     redstone.setBundledOutput(kabel, colors.lime+colors.red)
  181.     term.setCursorPos(1,2)
  182.             write "rc-f  "
  183.     else
  184.     term.setCursorPos(1,2)
  185.             write "ERROR "
  186.     end
  187. end
  188.  
  189. function nuclear()
  190. while true do
  191. local f=fs.open("status.cfg","w")
  192. f.writeLine(reactor_start)
  193. f.writeLine(cooler1)
  194. f.writeLine(cooler2)
  195. f.close()
  196.  
  197. energy_read = redstone.testBundledInput(kabel, colors.lightBlue)
  198. cooler1 = redstone.testBundledInput(kabel, colors.red)
  199. cooler2 = redstone.testBundledInput(kabel, colors.lime)
  200. reactor_start = redstone.testBundledInput(kabel, colors.white)
  201.  
  202. x,y = term.getSize()
  203. os.startTimer(0.5)
  204. term.setBackgroundColor(colors.white)
  205. term.setTextColor(colors.black)
  206. term.clear()
  207. paintutils.drawLine(1, 19, 51, 19, colors.lightGray)
  208. term.setCursorPos(46,19)
  209. write(textutils.formatTime(os.time(), true))
  210. term.setBackgroundColor(colors.gray)
  211. term.setCursorPos(1,19)
  212. write"MENU"
  213. term.setBackgroundColor(colors.white)
  214. term.setTextColor(colors.green)
  215. prc (" Nuclear control", 1)
  216. term.setTextColor(colors.black)
  217. term.setCursorPos(35,3)
  218. write ("Reactor : ")
  219. term.setCursorPos(35,4)
  220. write "Cooler 1: "
  221. term.setCursorPos(35,5)
  222. write "Cooler 2: "
  223. term.setCursorPos(35,7)
  224. write "Energy  : "
  225.  
  226. term.setCursorPos(45,3)
  227.     if reactor_start == true then
  228.     term.setTextColor(colors.green)
  229.     reactor_status = "Running"
  230.     else
  231.     term.setTextColor(colors.red)
  232.     reactor_status = "Stoped"
  233.     end
  234. write (reactor_status)
  235.  
  236. term.setCursorPos(45,4)
  237.     if cooler1 == true then
  238.     term.setTextColor(colors.green)
  239.     cooler1_status = "Running"
  240.     else
  241.     term.setTextColor(colors.red)
  242.     cooler1_status = "Stoped"
  243.     end
  244. write (cooler1_status)
  245.  
  246. term.setCursorPos(45,5)
  247.     if cooler2 == true then
  248.     term.setTextColor(colors.green)
  249.     cooler2_status = "Running"
  250.     else
  251.     term.setTextColor(colors.red)
  252.     cooler2_status = "Stoped"
  253.     end
  254. write (cooler2_status)
  255.  
  256. term.setCursorPos(45,7)
  257.     if energy_read == true then
  258.     term.setTextColor(colors.green)
  259.     energy_status = "Running"
  260.     else
  261.     term.setTextColor(colors.red)
  262.     energy_status = "Stoped"
  263.     end
  264. write (energy_status)
  265.  
  266. term.setBackgroundColor(colors.lightGray)
  267. term.setTextColor(colors.black)
  268. term.setCursorPos(5,4)
  269. write " Cooler  1 "
  270. term.setCursorPos(5,6)
  271. write " Cooler  2 "
  272. term.setCursorPos(5,8)
  273. write "  Reactor  "
  274. term.setCursorPos(5,9)
  275.     if reactor_start == true then
  276.     write "    STOP   "
  277.     else
  278.     write "   START   "
  279.     end
  280.  
  281.  
  282.  
  283.  
  284.  
  285. event, param1, x,y = os.pullEvent()
  286.     if event == "mouse_click" and x >= 5 and x <= 16 and y == 4 then
  287.         term.setBackgroundColor(colors.gray)
  288.         term.setTextColor(colors.white)
  289.         term.setCursorPos(5,4)
  290.         write " Cooler  1 "
  291.             if cooler1 == true then
  292.             cooler1_click = 2
  293.             else
  294.             cooler1_click = 1
  295.             end
  296.             redstoneset()
  297.         sleep (0.5)
  298.     elseif event == "mouse_click" and x >= 5 and x <= 16 and y == 6 then
  299.         term.setBackgroundColor(colors.gray)
  300.         term.setTextColor(colors.white)
  301.         term.setCursorPos(5,6)
  302.         write " Cooler  2 "
  303.         if cooler2 == true then
  304.             cooler2_click = 2
  305.             else
  306.             cooler2_click = 1
  307.             end
  308.             redstoneset()
  309.         sleep (0.5)
  310.     elseif event == "mouse_click" and x >= 5 and x <= 16 and y >= 8 and y <= 9 then
  311.         term.setBackgroundColor(colors.gray)
  312.         term.setTextColor(colors.white)
  313.         term.setCursorPos(5,8)
  314.         write "  Reactor  "
  315.         term.setCursorPos(5,9)
  316.             if reactor_start == true then
  317.             write "    STOP   "
  318.             else
  319.             write "   START   "
  320.             end
  321.            
  322.         if reactor_start == true then
  323.             reactor_click = 2
  324.             else
  325.             reactor_click = 1
  326.             end
  327.         reactorset()
  328.            
  329.         sleep (0.5)
  330.     elseif event == "mouse_click" and x >= 1 and x <= 5 and y == 19 then
  331.         term.setTextColor(colors.white)
  332.         term.setCursorPos(1,19)
  333.         write "MENU"
  334.         local myWindow = window.create(term.current(),2,17,8,19)
  335.         myWindow.setBackgroundColor(colors.lightGray)
  336.         myWindow.clear()
  337.         term.setBackgroundColor(colors.gray)
  338.         term.setCursorPos(2,15)
  339.         write "          "
  340.         term.setCursorPos(2,16)
  341.         write " Options  "
  342.         term.setCursorPos(2,17)
  343.         write " Sleep    "
  344.         term.setCursorPos(2,18)
  345.         write " Restart  "
  346.         term.setCursorPos(2,19)
  347.         write " Shutdown "
  348.        
  349.             while true do
  350.             local event, button, x, y = os.pullEvent("mouse_click")
  351.             xy = x..","..y
  352.    
  353.                 if (x >= 1 and x <= 10 and y == 17) and (button == 1 or button == 2)then
  354.                 spanek ()
  355.                 elseif (x >= 1 and x <= 10 and y == 18) and (button == 1 or button == 2)then
  356.                 restart ()
  357.                 elseif (x >= 1 and x <= 10 and y == 19) and (button == 1 or button == 2)then
  358.                 vypnout ()
  359.                 elseif (x >= 1 and x <= 10 and y == 16) and (button == 1 or button == 2)then
  360.                 if not fs.exists ("/setting") then
  361.                 shell.run("pastebin get 3KJW5cP0 /setting")
  362.                 end
  363.                 shell.run("/setting")
  364.                 else
  365.                 nuclear()      
  366.                 end
  367.             end          
  368.         return
  369.         false -- Here is the important part.
  370.         end
  371.     end
  372. end
  373.  
  374. function setting()
  375. end
  376.  
  377. function spanek ()
  378.     term.setBackgroundColor(colors.lightGray)
  379.     term.clear()
  380.     sleep (0.1)
  381.     term.setBackgroundColor(colors.gray)
  382.     term.clear()
  383.     sleep (0.1)
  384.     term.setBackgroundColor(colors.black)
  385.     term.setTextColor(colors.black)
  386.     term.clear()
  387.    
  388.     while true do
  389.           local event, button, xPos, yPos = os.pullEvent("mouse_click")
  390.           desktop ()
  391.     end
  392. end
  393.  
  394. function vypnout ()
  395.     term.setBackgroundColor(colors.lightGray)
  396.     term.clear()
  397.     sleep (0.1)
  398.     term.setBackgroundColor(colors.gray)
  399.     term.clear()
  400.     sleep (0.1)
  401.     term.setBackgroundColor(colors.white)
  402.     term.setTextColor(colors.black)
  403.     term.clear()
  404.     term.setCursorPos(23, 7)
  405.     prc ("Shutting down")
  406.     term.setBackgroundColor(colors.white)
  407.     term.setTextColor(colors.blue)
  408.     term.setCursorPos(20,18)
  409.     print"  Pepek"
  410.     term.setCursorPos(28,18)
  411.     print"Soft  "
  412.     term.setCursorPos(27,18)
  413.     term.setTextColor(colors.lime)
  414.     print"@"
  415.     sleep (2)
  416.     if fs.exists ("/online") then
  417.     fs.delete ("/online")
  418.     end
  419.     os.shutdown ()
  420. end
  421.  
  422. function restart ()
  423.     term.setBackgroundColor(colors.lightGray)
  424.     term.clear()
  425.     sleep (0.1)
  426.     term.setBackgroundColor(colors.gray)
  427.     term.clear()
  428.     sleep (0.1)
  429.     term.setBackgroundColor(colors.white)
  430.     term.setTextColor(colors.black)
  431.     term.clear()
  432.     term.setCursorPos(23, 7)
  433.     prc ("Restarting")
  434.     term.setBackgroundColor(colors.white)
  435.     term.setTextColor(colors.blue)
  436.     term.setCursorPos(20,18)
  437.     print"  Pepek"
  438.     term.setCursorPos(28,18)
  439.     print"Soft  "
  440.     term.setCursorPos(27,18)
  441.     term.setTextColor(colors.lime)
  442.     print"@"
  443.     sleep (1)
  444.     term.setBackgroundColor(colors.black)
  445.     term.clear()
  446.     sleep (2)
  447.     if fs.exists ("/online") then
  448.     fs.delete ("/online")
  449.     end
  450.     os.reboot ()
  451. end
  452.  
  453. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement