Advertisement
TheSpicePhantom

blsOS

May 8th, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.96 KB | None | 0 0
  1. os.loadAPI("touchAPI")
  2.  
  3. touchAPILocation = {}
  4. mode = ""
  5. pcState = ""
  6.  
  7. function bootINIT()
  8.   local perList = peripheral.getNames()  
  9.   for i=1,#perList do
  10.     if peripheral.getType(perList[i]) == "monitor" then
  11.       touchAPILocation = perList[i]
  12.       mon = peripheral.wrap(perList[i])
  13.       touch = touchAPI.new(touchAPILocation)
  14.     elseif peripheral.getType(perList[i]) == "BigReactors-Reactor" then
  15.       r = peripheral.wrap(perList[i])
  16.       enMaxR = 10000000
  17.     elseif peripheral.getType(perList[i]) == "dimension_builder" then
  18.       dim = peripheral.wrap(perList[i])
  19.     elseif peripheral.getType(perList[i]) == "tile_blockcapacitorbank_name" then
  20.       c = peripheral.wrap(perList[i])
  21.       capBankLocation = perList[i]
  22.     elseif peripheral.getType(perList[i]) == "tilecontroller" then
  23.       ae = peripheral.wrap(perList[i])
  24.     elseif peripheral.getType(perList[i]) == "computer" then
  25.       pc = peripheral.wrap(perList[i])
  26.     end
  27.   end
  28. end
  29. bootINIT()
  30. mon.setBackgroundColor(colors.gray)  
  31.  
  32. function getEvent()
  33.   local event,but
  34.   while true do
  35.     local timer = os.startTimer(0.5)
  36.     event, but = touch:handleEvents(os.pullEvent())
  37.     if event == "button_click" then    
  38.       if but == "Speicher" then
  39.         mode = "Speicher"
  40.         mon.clear()
  41.         touch:draw()
  42.       elseif but == "Reaktor" then
  43.         mode = "Reaktor"
  44.         mon.clear()
  45.         touch:draw()
  46.       elseif but == "Dimension" then
  47.         mode = "Dimension"
  48.       elseif but == "AE-System" then
  49.         mode = "AE-System"
  50.         mon.clear()
  51.         touch:draw()
  52.       end
  53.       touch.buttonList[but].func()
  54.     else
  55.       if mode == "Speicher" then
  56.         getEnergyInfo()
  57.       elseif mode == "Reaktor" then
  58.       elseif mode == "Dimension" then
  59.       elseif mode == "AE-System" then
  60.         getAeInfo()
  61.       end
  62.       sleep(0.5)
  63.     end
  64.   end
  65. end
  66.  
  67. function getEnergyInfo()
  68. mon.setBackgroundColor(colors.black)
  69. enMIO = c.getMaxEnergyStored()  
  70.     if peripheral.getType(capBankLocation) == "tile_blockcapacitorbank_name" then
  71.         enC = c.getEnergyStored()
  72.         enPer = math.floor(enC/enMIO*100)
  73.         if enMIO == 25000000 then
  74.           cType = "Vibrant Capacitor Bank"
  75.         elseif enMIO == 5000000 then
  76.           cType = "Capacitor Bank        "
  77.         elseif enMIO == 1000000 then
  78.           cType = "Basic Capacitor Bank  "
  79.         end
  80.         enC = c.getEnergyStored()
  81.         sleep(0.1)
  82.         mon.setBackgroundColor(colors.black)
  83.         mon.setCursorPos(3,4)
  84.         mon.write("Speicher Typ: "..cType)
  85.         mon.setCursorPos(3,5)
  86.         mon.write("Fuellstand:   "..enPer.." % ")
  87.       end
  88. end
  89.  
  90. function createTermScreen()
  91. local menutext = colors.black
  92. term.clear()
  93. paintutils.drawImage(paintutils.loadImage("screensaver"),2,2)
  94. end
  95. createTermScreen()
  96.  
  97. function getCenterPos()
  98.   local x, y = mon.getSize()
  99.   xCen = x/2
  100.   yCen = y/2
  101. end
  102.  
  103. function UpdateManual()
  104.   getCenterPos()
  105.   mon.clear()
  106.   mon.setBackgroundColor(colors.gray)
  107.   mon.setCursorPos(xCen, yCen)
  108.   shell.run("rm Update")
  109.   shell.run("rm blsOS")
  110.   sleep(0.2)
  111.   shell.run("pastebin get cTQQpqxR Update")
  112.   shell.run("pastebin get Xgih2Zyu blsOS")
  113.   sleep(2)
  114.   shell.run("Update")
  115.   mon.write("Neueste Version installiert!")
  116.   mon.clear()
  117.   os.reboot()
  118. end
  119.  
  120. function getAeInfo()
  121.   aeN = ae.getEnergyStored()
  122.   aeM = ae.getMaxEnergyStored()
  123.   aePer = math.floor(aeN/aeM*100)
  124.   mon.setBackgroundColor(colors.black)
  125.   mon.setCursorPos(3,4)
  126.   mon.write("Me-System-Strom")
  127.   mon.setCursorPos(3,5)
  128.   mon.write("Fuellstand: "..aePer.." % ")
  129. end
  130.  
  131. function getReactorInfo()
  132.   mon.setBackgroundColor(colors.black)
  133.   mon.setCursorPos(3,4)
  134.   mon.write("Fahre Turbinen Controller herunter...")
  135.   pc.shutdown()
  136.   mon.setCursorPos(3,5)
  137.   os.sleep(0.2)
  138.   mon.write("Starte Synchronisation...")
  139.   mon.setCursorPos(3,6)
  140.   os.sleep(0.2)
  141.   mon.write("Fahre Turbinen Controller hoch...")
  142.   pc.turnOn()
  143.     pcState = "on"
  144. end
  145.  
  146. touch:add("AE-System", getAeInfo, 36, 1, 46, 1)
  147. touch:add("Speicher", getEnergyInfo, 25, 1, 34, 1)
  148. touch:add("Reaktor", getReactorInfo, 15, 1, 23, 1)
  149. touch:add("Dimension", getDimensionBuilderInfo, 3, 1, 13, 1)
  150. touch:add("Update", UpdateManual, 3, 19, 12, 19)
  151. touch:add("Neustart", function() touch:flash("Neustart") os.reboot() end, 14, 19, 23, 19)
  152. touch:draw()
  153.  
  154. function start()
  155.   local event,but
  156.   while true do
  157.     event,but = touch:handleEvents(os.pullEvent())
  158.     if event == "button_click" then
  159.       if but == "Speicher" then
  160.         mode = "Speicher"
  161.         break
  162.       elseif but == "Reaktor" then
  163.         mode = "Reaktor"
  164.         break
  165.       elseif but == "Dimension" then
  166.         mode = "Dimension"
  167.         break
  168.       elseif but == "AE-System" then
  169.         mode = "AE-System"
  170.         break
  171.       elseif but == "Update" or but == "Neustart" then
  172.         break
  173.       end
  174.     end
  175.   end
  176.   touch.buttonList[but].func()
  177. end
  178.  
  179. start()
  180. getEvent()
  181.  
  182.  
  183. --while true do
  184. --  getEnergyInfo()
  185. --  getEvent()
  186. --end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement