Advertisement
EatMyNoodle

turbineControl

Jun 3rd, 2016
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.68 KB | None | 0 0
  1. -- Reaktor- und Turbinenprogramm von Thor_s_Crafter --
  2. -- Version 2.0 -- modded by EatMyNoodle - 6280
  3. -- http://pastebin.com/edit/iKzit2xt
  4. -- Turbinenkontrolle --
  5.  
  6. --Lädt die Touchpoint API
  7. os.loadAPI("touchpoint")
  8.  
  9. local page = touchpoint.new(touchpointLocation)
  10. local lastStat = 0
  11. local currStat = 0
  12. local rOn
  13. local rOff
  14. local tOn
  15. local tOff
  16. local cOn
  17. local cOff
  18. local modeA
  19. local modeM
  20. if lang == "de" then
  21. rOn = {" Ein ",label = "reactorOn"}
  22. rOff = {" Aus ",label = "reactorOn"}
  23. tOn = {" Ein ",label = "turbineOn"}
  24. tOff = {" Aus ",label = "turbineOn"}
  25. cOn = {" Ein ",label = "coilsOn"}
  26. cOff = {" Aus ",label = "coilsOn"}
  27. modeA = {" Automatisch ",label = "modeSwitch"}
  28. modeM = {" Manuell ",label = "modeSwitch"}
  29. elseif lang == "en" then
  30. rOn = {" On ",label = "reactorOn"}
  31. rOff = {" Off ",label = "reactorOn"}
  32. tOn = {" On ",label = "turbineOn"}
  33. tOff = {" Off ",label = "turbineOn"}
  34. cOn = {" On ",label = "coilsOn"}
  35. cOff = {" Off ",label = "coilsOn"}
  36. modeA = {" Automatic ",label = "modeSwitch"}
  37. modeM = {" Manual ",label = "modeSwitch"}
  38. end
  39.  
  40.  
  41. --Initialisiert das Programm
  42. function startAutoMode()
  43. checkPeripherals()
  44. findOptimalFuelRodLevel()
  45.  
  46. --Turbinen auf 1820 RPM bringen
  47. term.clear()
  48. term.setCursorPos(1,1)
  49. print("Getting all Turbines to 6280 RPM...")
  50.  
  51. mon.setBackgroundColor(backgroundColor)
  52. mon.setTextColor(textColor)
  53. mon.clear()
  54. mon.setCursorPos(1,1)
  55. --In Deutsch
  56. if lang == "de" then
  57. mon.write("Bringe Turbinen auf 6280 RPM. Bitte warten...")
  58. --In Englisch
  59. elseif lang == "en" then
  60. mon.write("Getting Turbines to 6280 RPM. Please wait...")
  61. end
  62.  
  63. while not allAtTargetSpeed() do
  64. getToTargetSpeed()
  65. sleep(1)
  66. term.setCursorPos(1,2)
  67. for i=0,amountTurbines,1 do
  68. print("Speed: "..t[i].getRotorSpeed().." ")
  69.  
  70. local speed = tostring(t[i].getRotorSpeed())
  71. local speedstr = string.sub(speed,0,4)
  72. mon.setTextColor(textColor)
  73. mon.setCursorPos(1,(i+3))
  74. mon.write("Turbine "..(i+1)..": "..speedstr.." RPM")
  75. if t[i].getRotorSpeed() > 6280 then
  76. mon.setTextColor(colors.green)
  77. mon.write(" OK ")
  78. else
  79. mon.setTextColor(colors.red)
  80. mon.write(" ...")
  81. end
  82. end
  83. end
  84.  
  85. --Schalte Reaktor & Turbinen an
  86. r.setActive(true)
  87. allTurbinesOn()
  88.  
  89. --Anzeige auf Default setzen
  90. term.clear()
  91. term.setCursorPos(1,1)
  92.  
  93. mon.setBackgroundColor(backgroundColor)
  94. mon.clear()
  95. mon.setTextColor(textColor)
  96. mon.setCursorPos(1,1)
  97.  
  98. --Buttons erstellen
  99. createAllButtons()
  100.  
  101. --Zeige erste Turbine an (default)
  102. printStatsAuto(0)
  103.  
  104. while true do
  105. clickEvent()
  106. end
  107. end
  108. --Ende der startAutoMode()-Funktion
  109.  
  110. function startManualMode()
  111. checkPeripherals()
  112. createAllButtons()
  113. createManualButtons()
  114. for i=0,#t do
  115. t[i].setFluidFlowRateMax(2000)
  116. end
  117. printStatsMan(0)
  118. while true do
  119. clickEvent()
  120. end
  121. end
  122.  
  123. --Überprüft auf Fehler beim Starten
  124. function checkPeripherals()
  125. mon.setBackgroundColor(colors.black)
  126. mon.clear()
  127. mon.setCursorPos(1,1)
  128. mon.setTextColor(colors.red)
  129. term.clear()
  130. term.setCursorPos(1,1)
  131. term.setTextColor(colors.red)
  132. if t[0] == nil then
  133. if lang == "de" then
  134. mon.write("Turbinen nicht gefunden! Bitte pruefen und den Computer neu starten (Strg+R gedrueckt halten)")
  135. error("Turbinen nicht gefunden! Bitte pruefen und den Computer neu starten (Strg+R gedrueckt halten)")
  136. elseif lang == "en" then
  137. mon.write("Turbines not found! Please check and reboot the computer (Press and hold Ctrl+R)")
  138. error("Turbines not found! Please check and reboot the computer (Press and hold Ctrl+R)")
  139. end
  140. end
  141. if r == "" then
  142. if lang == "de" then
  143. mon.write("Reaktor nicht gefunden! Bitte pruefen und den Computer neu starten (Strg+R gedrueckt halten)")
  144. error("Reaktor nicht gefunden! Bitte pruefen und den Computer neu starten (Strg+R gedrueckt halten)")
  145. elseif lang == "en" then
  146. mon.write("Reactor not found! Please check and reboot the computer (Press and hold Ctrl+R)")
  147. error("Reactor not found! Please check and reboot the computer (Press and hold Ctrl+R)")
  148. end
  149. end
  150. if v == "" then
  151. if lang == "de" then
  152. mon.write("Energiezelle nicht gefunden! Bitte pruefen und den Computer neu starten (Strg+R gedrueckt halten)")
  153. error("Energiezelle nicht gefunden! Bitte pruefen und den Computer neu starten (Strg+R gedrueckt halten)")
  154. elseif lang == "en" then
  155. mon.write("Energy Cell not found! Please check and reboot the computer (Press and hold Ctrl+R)")
  156. error("Energy Cell not found! Please check and reboot the computer (Press and hold Ctrl+R)")
  157. end
  158. end
  159. end
  160.  
  161. -- Kleine Methoden
  162. function getEnergy()
  163. return v.getEnergyStored()
  164. end
  165. function getEnergyMax()
  166. return v.getMaxEnergyStored()
  167. end
  168. function getEnergyPer()
  169. local en = getEnergy()
  170. local enMax = getEnergyMax()
  171. local enPer = math.floor(en/enMax*100)
  172. return enPer
  173. end
  174.  
  175. --Schaltet den Reaktor um
  176. function toggleReactor()
  177. r.setActive(not r.getActive())
  178. page:toggleButton("reactorOn")
  179. if r.getActive() then
  180. page:rename("reactorOn",rOn,true)
  181. else
  182. page:rename("reactorOn",rOff,true)
  183. end
  184. end
  185.  
  186. --Schaltet eine Turbine um
  187. function toggleTurbine(i)
  188. t[i].setActive(not t[i].getActive())
  189. page:toggleButton("turbineOn")
  190. if t[i].getActive() then
  191. page:rename("turbineOn",tOn,true)
  192. else
  193. page:rename("turbineOn",tOff,true)
  194. end
  195. end
  196.  
  197. function toggleCoils(i)
  198. t[i].setInductorEngaged(not t[i].getInductorEngaged())
  199. page:toggleButton("coilsOn")
  200. if t[i].getInductorEngaged() then
  201. page:rename("coilsOn",cOn,true)
  202. else
  203. page:rename("coilsOn",cOff,true)
  204. end
  205. end
  206.  
  207. --Alle Turbinen an (Coils an, FluidRate 2000mb/t)
  208. function allTurbinesOn()
  209. for i=0,amountTurbines,1 do
  210. t[i].setActive(true)
  211. t[i].setInductorEngaged(true)
  212. t[i].setFluidFlowRateMax(2000)
  213. end
  214. end
  215.  
  216. --Alle Turbinen aus (Coils aus, FluidRate 0mb/t)
  217. function allTurbinesOff()
  218. for i=0,amountTurbines,1 do
  219. t[i].setInductorEngaged(false)
  220. t[i].setFluidFlowRateMax(0)
  221. end
  222. end
  223.  
  224. --Eine Turbine an
  225. function turbineOn(i)
  226. t[i].setInductorEngaged(true)
  227. t[i].setFluidFlowRateMax(2000)
  228. end
  229.  
  230. --Eine Turbine aus
  231. function turbineOff(i)
  232. t[i].setInductorEngaged(false)
  233. t[i].setFluidFlowRateMax(0)
  234. end
  235.  
  236. --Sucht das optimale RodLevel
  237. function findOptimalFuelRodLevel()
  238. --Versuche Level aus der Config zu laden
  239. if not (math.floor(rodLevel) == 0) then
  240. r.setAllControlRodLevels(rodLevel)
  241.  
  242. else
  243. --Bringe Turbinen unter 99 Grad
  244. getTo99c()
  245.  
  246. --Schalte alles ein
  247. r.setActive(true)
  248. allTurbinesOn()
  249.  
  250. --Lokale Variablen zur Berechnung
  251. local controlRodLevel = 99
  252. local optRodLevelFound = true
  253. local steamOutput = r.getHotFluidProducedLastTick()
  254. local targetSteamOutput = 2000*(amountTurbines+1)
  255.  
  256. --Anzeige auf dem Bildschirm
  257. mon.setBackgroundColor(backgroundColor)
  258. mon.setTextColor(textColor)
  259. mon.clear()
  260. --In Deutsch
  261. if lang == "de" then
  262. mon.setCursorPos(1,1)
  263. mon.write("Finde optimales FuelRod Level...")
  264. mon.setCursorPos(1,5)
  265. mon.write("Gesuchter Steam-Output: "..targetSteamOutput.."mb/t")
  266. --In Englisch
  267. elseif lang == "en" then
  268. mon.setCursorPos(1,1)
  269. mon.write("Finding optimale FuelRod Level...")
  270. mon.setCursorPos(1,5)
  271. mon.write("Target Steam-Output: "..targetSteamOutput.."mb/t")
  272. end
  273.  
  274. --Läuft durch bis das optimale Level gefunden wurde
  275. while optRodLevelFound do
  276. r.setAllControlRodLevels(controlRodLevel)
  277. steamOutput = r.getHotFluidProducedLastTick()
  278.  
  279. mon.setCursorPos(1,3)
  280. mon.write("FuelRod Level: "..controlRodLevel.." ")
  281. --In Deutsch
  282. if lang == "de" then
  283. mon.setCursorPos(1,6)
  284. mon.write("Aktueller Steam-Output: "..steamOutput.."mb/t ")
  285. --In Englisch
  286. elseif lang == "en" then
  287. mon.setCursorPos(1,6)
  288. mon.write("Current Steam-Output: "..steamOutput.."mb/t ")
  289. end
  290. sleep(1.5)
  291.  
  292. if steamOutput < targetSteamOutput then
  293. controlRodLevel = controlRodLevel - 1
  294. r.setAllControlRodLevels(controlRodLevel)
  295.  
  296. --Level gefunden
  297. else
  298. r.setAllControlRodLevels(controlRodLevel)
  299. rodLevel = controlRodLevel
  300. saveOptionFile()
  301. optRodLevelFound = false
  302. end --else
  303. end --while
  304. end --else
  305. end --function
  306. --Ende der findOptimalFuelRodlevel()-Funktion
  307.  
  308. --Bringt den Reaktor unter 99 Grad
  309. function getTo99c()
  310. mon.setBackgroundColor(backgroundColor)
  311. mon.setTextColor(textColor)
  312. mon.clear()
  313. mon.setCursorPos(1,1)
  314. --In Deutsch
  315. if lang == "de" then
  316. mon.write("Bringe Reaktor unter 99 Grad...")
  317. --In Englisch
  318. elseif lang == "en" then
  319. mon.write("Getting Reactor below 99c ...")
  320. end
  321.  
  322. --Schalte Reaktor und Turbinen aus
  323. r.setActive(false)
  324. allTurbinesOn()
  325.  
  326. --Lokale Variablen
  327. local fTemp = r.getFuelTemperature()
  328. local cTemp = r.getCasingTemperature()
  329. local isNotBelow = true
  330.  
  331. --Läuft durch, bis die Kern-und Hüllentemperatur unter 99 Grad sind
  332. while isNotBelow do
  333. term.setCursorPos(1,2)
  334. print("CoreTemp: "..fTemp.." ")
  335. print("CasingTemp: "..cTemp.." ")
  336.  
  337. fTemp = r.getFuelTemperature()
  338. cTemp = r.getCasingTemperature()
  339.  
  340. if fTemp < 99 then
  341. if cTemp < 99 then
  342. isNotBelow = false
  343. end
  344. end
  345.  
  346. sleep(1)
  347. end
  348. end
  349. --Ende der getTo99c()-Funktion
  350.  
  351. --Überprüft das Energielevel der Capacitorbank
  352. --und verwaltet die Turbinen und den Reaktor entsprechend
  353. function checkEnergyLevel()
  354. --Bildschirmausgabe
  355. printStatsAuto(currStat)
  356. --Energielevel über der Ausschalt-Grenze (def: 90%)
  357. if getEnergyPer() >= reactorOffAt then
  358. printStatsAuto(currStat)
  359. print("Energy >= reactorOffAt")
  360. --Überprüft, ob die Turbinen über 6280 RPM sind
  361. while not allAtTargetSpeed() do
  362. print("while...")
  363. getToTargetSpeed()
  364. printStatsAuto(currStat)
  365. sleep(0.2)
  366. end
  367. --Alle Turbinen sind auf 6280 RPM
  368. --Schaltet Turbinen und Reaktor aus
  369. if allAtTargetSpeed() then
  370. print("AllAtTargetSpeed.")
  371. allTurbinesOff()
  372. r.setActive(false)
  373. end
  374. print("end while")
  375.  
  376. --Energielevel ist unter der Einschalt-Grenze
  377. elseif getEnergyPer() < reactorOnAt then
  378. --Bringt Turbinen auf 6280 RPM
  379. getToTargetSpeed()
  380. --Schaltet den Reaktor und die Turbinen ein
  381. if allAtTargetSpeed() then
  382. r.setActive(true)
  383. allTurbinesOn()
  384. end
  385.  
  386. --Energielevel ist zwischen Ober-und Untergrenze
  387. else
  388. printStatsAuto(currStat)
  389. --Behält Turbinen konstant auf 6280 RPM
  390. for i=0,amountTurbines,1 do
  391. if t[i].getInductorEngaged() and t[i].getRotorSpeed() < 6280 then
  392. t[i].setInductorEngaged(false)
  393. while t[i].getRotorSpeed() < 6280 do
  394. printStatsAuto(currStat)
  395. sleep(0.4)
  396. end
  397. t[i].setInductorEngaged(true)
  398. end
  399. end
  400. end
  401. end
  402. --Ende der checkEnergyLevel()-Funktion
  403.  
  404. --Bringt Turbinen auf 6280 RPM
  405. function getToTargetSpeed()
  406. for i=0,amountTurbines,1 do
  407. if t[i].getRotorSpeed() <= 6280 then
  408. r.setActive(true)
  409. t[i].setActive(true)
  410. t[i].setInductorEngaged(false)
  411. t[i].setFluidFlowRateMax(2000)
  412. end
  413. if t[i].getRotorSpeed() > 6280 then
  414. turbineOff(i)
  415. end
  416. end
  417. end
  418.  
  419. --Gibt true zurück, wenn alle Turbinen auf 6280 RPM sind
  420. function allAtTargetSpeed()
  421. for i=0,amountTurbines,1 do
  422. if t[i].getRotorSpeed() <= 6280 then
  423. return false
  424. end
  425. end
  426. return true
  427. end
  428.  
  429. function run(program)
  430. shell.run(program)
  431. error("end turbineControl")
  432. end
  433.  
  434. function switchMode()
  435. if overallMode == "auto" then
  436. overallMode = "manual"
  437. saveOptionFile()
  438. elseif overallMode == "manual" then
  439. overallMode = "auto"
  440. saveOptionFile()
  441. end
  442. page = ""
  443. mon.clear()
  444. run("turbineControl")
  445. end
  446.  
  447. --Erstellt alle Buttons
  448. function createAllButtons()
  449. local xMin = 40
  450. local xMax = 52
  451. local yMin = 4
  452. local yMax = 4
  453.  
  454. --Turbinenbuttons
  455. for i=0,amountTurbines,1 do
  456. --Gerade Anzahl (wird in der linken Spalte angezeigt)
  457. if math.floor(i/2)*2 == i then
  458. if overallMode == "auto" then
  459. page:add("Turbine "..(i+1),function() printStatsAuto(i) end,xMin,yMin,xMax,yMax)
  460. elseif overallMode == "manual" then
  461. page:add("Turbine "..(i+1),function() printStatsMan(i) end,xMin,yMin,xMax,yMax)
  462. end
  463. else
  464. --Ungerade Anzahl (wird in der rechten Spalte angezeigt)
  465. if overallMode == "auto" then
  466. page:add("Turbine "..(i+1),function() printStatsAuto(i) end,xMin+15,yMin,xMax+15,yMax)
  467. elseif overallMode == "manual" then
  468. page:add("Turbine "..(i+1),function() printStatsMan(i) end,xMin+15,yMin,xMax+15,yMax)
  469. end
  470. yMin = yMin + 2
  471. yMax = yMax + 2
  472. end
  473. end
  474. page:add("modeSwitch",switchMode,19,22,33,22)
  475. if overallMode == "auto" then
  476. page:rename("modeSwitch",modeA,true)
  477. elseif overallMode == "manual" then
  478. page:rename("modeSwitch",modeM,true)
  479. end
  480. --In Deutsch
  481. if lang == "de" then
  482. page:add("Neu starten",restart,2,18,17,18)
  483. page:add("Optionen",function() run("editOptions") end,2,20,17,20)
  484. page:add("Hauptmenue",function() run("menu") end,2,22,17,22)
  485. --In Englisch
  486. elseif lang == "en" then
  487. page:add("Reboot",restart,2,18,17,18)
  488. page:add("Options",function() run("editOptions") end,2,20,17,20)
  489. page:add("Main Menu",function() run("menu") end,2,22,17,22)
  490. end
  491. page:draw()
  492. end
  493.  
  494. function createManualButtons()
  495. --Reaktor Button
  496. page:add("reactorOn",toggleReactor,11,11,15,11)
  497. if r.getActive() then
  498. page:rename("reactorOn",rOn,true)
  499. page:toggleButton("reactorOn")
  500. else
  501. page:rename("reactorOn",rOff,true)
  502. end
  503. --Turbinen Button (An/Aus)
  504. page:add("turbineOn",function() toggleTurbine(currStat) end,20,13,24,13)
  505. if t[currStat].getActive() then
  506. page:rename("turbineOn",tOn,true)
  507. page:toggleButton("turbineOn")
  508. else
  509. page:rename("turbineOn",tOff,true)
  510. end
  511. -- Turbinen Button (Coils)
  512. page:add("coilsOn",function() toggleCoils(currStat) end,9,15,13,15)
  513. if t[currStat].getInductorEngaged() then
  514. page:rename("coilsOn",cOn,true)
  515. else
  516. page:rename("coilsOn",cOff,true)
  517. end
  518. page:draw()
  519. end
  520.  
  521.  
  522. --Überprüft Eingaben des Benutzers auf dem Touchscreen
  523. function clickEvent()
  524.  
  525. if overallMode == "auto" then
  526. printStatsAuto(currStat)
  527. checkEnergyLevel()
  528. elseif overallMode == "manual" then
  529. printStatsMan(currStat)
  530. end
  531.  
  532. local time = os.startTimer(0.5)
  533.  
  534. local event, but = page:handleEvents(os.pullEvent())
  535. print(event)
  536.  
  537. if event == "button_click" then
  538. page:flash(but)
  539. page.buttonList[but].func()
  540. elseif event == "terminate" then
  541. sleep(2)
  542. mon.clear()
  543. mon.setCursorPos(1,1)
  544. mon.setTextColor(colors.red)
  545. mon.write("Programm abgebrochen!")
  546. error("Manuell abgebrochen")
  547. end
  548. end
  549.  
  550.  
  551. --Gibt alle Daten auf dem Bildschirm aus - Auto Modus
  552. function printStatsAuto(turbine)
  553. currStat = turbine
  554.  
  555. if not page.buttonList["Turbine "..currStat+1].active then
  556. page:toggleButton("Turbine "..currStat+1)
  557. end
  558. if currStat ~= lastStat then
  559. if page.buttonList["Turbine "..lastStat+1].active then
  560. page:toggleButton("Turbine "..lastStat+1)
  561. end
  562. end
  563.  
  564. local rfGen = 0
  565. for i=0,amountTurbines,1 do
  566. rfGen = rfGen + t[i].getEnergyProducedLastTick()
  567. end
  568.  
  569. mon.setBackgroundColor(tonumber(backgroundColor))
  570. mon.setTextColor(tonumber(textColor))
  571.  
  572. mon.setCursorPos(2,2)
  573. if lang == "de" then
  574. mon.write("Energie: "..getEnergyPer().."% ")
  575. elseif lang == "en" then
  576. mon.write("Energy: "..getEnergyPer().."% ")
  577. end
  578.  
  579. mon.setCursorPos(2,3)
  580. mon.setBackgroundColor(colors.green)
  581. for i=0 ,getEnergyPer(),5 do
  582. mon.write(" ")
  583. end
  584.  
  585. mon.setBackgroundColor(colors.lightGray)
  586. local tmpEn = getEnergyPer()/5
  587. local pos = 22-(19-tmpEn)
  588. mon.setCursorPos(pos,3)
  589. for i=0,(19-tmpEn),1 do
  590. mon.write(" ")
  591. end
  592.  
  593. mon.setBackgroundColor(tonumber(backgroundColor))
  594.  
  595. mon.setCursorPos(2,5)
  596. if lang == "de" then
  597. mon.write("RF-Produktion: "..math.floor(rfGen).." RF/t ")
  598. elseif lang == "en" then
  599. mon.write("RF-Production: "..math.floor(rfGen).." RF/t ")
  600. end
  601.  
  602. mon.setCursorPos(2,7)
  603. if lang == "de" then
  604. mon.write("Reaktor: ")
  605. if r.getActive() then
  606. mon.setTextColor(colors.green)
  607. mon.write("an ")
  608. end
  609. if not r.getActive() then
  610. mon.setTextColor(colors.red)
  611. mon.write("aus")
  612. end
  613. elseif lang == "en" then
  614. mon.write("Reactor: ")
  615. if r.getActive() then
  616. mon.setTextColor(colors.green)
  617. mon.write("on ")
  618. end
  619. if not r.getActive() then
  620. mon.setTextColor(colors.red)
  621. mon.write("off")
  622. end
  623. end
  624.  
  625.  
  626. mon.setTextColor(tonumber(textColor))
  627.  
  628. mon.setCursorPos(2,9)
  629. local fuelCons = tostring(r.getFuelConsumedLastTick())
  630. local fuelCons2 = string.sub(fuelCons, 0,4)
  631.  
  632. if lang == "de" then
  633. mon.write("Reaktor-Verbrauch: "..fuelCons2.."mb/t ")
  634. mon.setCursorPos(2,10)
  635. mon.write("Steam: "..math.floor(r.getHotFluidProducedLastTick()).."mb/t ")
  636. mon.setCursorPos(40,2)
  637. mon.write("Turbinen: "..(amountTurbines+1).." ")
  638. mon.setCursorPos(19,20)
  639. mon.write("Modus:")
  640. mon.setCursorPos(2,12)
  641. mon.write("-- Turbine "..(turbine+1).." --")
  642. elseif lang == "en" then
  643. mon.write("Fuel Consumption: "..fuelCons2.."mb/t ")
  644. mon.setCursorPos(2,10)
  645. mon.write("Steam: "..math.floor(r.getHotFluidProducedLastTick()).."mb/t ")
  646. mon.setCursorPos(40,2)
  647. mon.write("Turbines: "..(amountTurbines+1).." ")
  648. mon.setCursorPos(19,20)
  649. mon.write("Mode:")
  650. mon.setCursorPos(2,12)
  651. mon.write("-- Turbine "..(turbine+1).." --")
  652. end
  653.  
  654. mon.setCursorPos(2,13)
  655. mon.write("Coils: ")
  656.  
  657. if t[turbine].getInductorEngaged() then
  658. mon.setTextColor(colors.green)
  659. if lang == "de" then
  660. mon.write("eingehaengt ")
  661. elseif lang == "en" then
  662. mon.write("engaged ")
  663. end
  664. end
  665. if t[turbine].getInductorEngaged() == false then
  666. mon.setTextColor(colors.red)
  667. if lang == "de" then
  668. mon.write("ausgehaengt ")
  669. elseif lang == "en" then
  670. mon.write("disengaged")
  671. end
  672. end
  673. mon.setTextColor(tonumber(textColor))
  674.  
  675. mon.setCursorPos(2,14)
  676. if lang == "de" then
  677. mon.write("Rotor Geschwindigkeit: ")
  678. mon.write(math.floor(t[turbine].getRotorSpeed()))
  679. mon.setCursorPos(2,15)
  680. mon.write("RF-Produktion: "..math.floor(t[turbine].getEnergyProducedLastTick()).." RF/t ")
  681. elseif lang == "en" then
  682. mon.write("Rotor Speed: ")
  683. mon.write(math.floor(t[turbine].getRotorSpeed()))
  684. mon.setCursorPos(2,15)
  685. mon.write("RF-Production: "..math.floor(t[turbine].getEnergyProducedLastTick()).." RF/t ")
  686. end
  687.  
  688. mon.setCursorPos(2,25)
  689. mon.write("Version "..version)
  690. lastStat = turbine
  691. end
  692.  
  693. --printStats - Manueller Modus
  694. function printStatsMan(turbine)
  695. currStat = turbine
  696.  
  697. if not page.buttonList["Turbine "..currStat+1].active then
  698. page:toggleButton("Turbine "..currStat+1)
  699. end
  700. if currStat ~= lastStat then
  701. if page.buttonList["Turbine "..lastStat+1].active then
  702. page:toggleButton("Turbine "..lastStat+1)
  703. end
  704. end
  705.  
  706. --Ein/Aus Buttons
  707. if t[currStat].getActive() and not page.buttonList["turbineOn"].active then
  708. page:rename("turbineOn",tOn,true)
  709. page:toggleButton("turbineOn")
  710. end
  711. if not t[currStat].getActive() and page.buttonList["turbineOn"].active then
  712. page:rename("turbineOn",tOff,true)
  713. page:toggleButton("turbineOn")
  714. end
  715. if t[currStat].getInductorEngaged() and not page.buttonList["coilsOn"].active then
  716. page:rename("coilsOn",cOn,true)
  717. page:toggleButton("coilsOn")
  718. end
  719. if not t[currStat].getInductorEngaged() and page.buttonList["coilsOn"].active then
  720. page:rename("coilsOn",cOff,true)
  721. page:toggleButton("coilsOn")
  722. end
  723.  
  724. mon.setBackgroundColor(tonumber(backgroundColor))
  725. mon.setTextColor(tonumber(textColor))
  726.  
  727. mon.setCursorPos(2,2)
  728. if lang == "de" then
  729. mon.write("Energie: "..getEnergyPer().."% ")
  730. elseif lang == "en" then
  731. mon.write("Energy: "..getEnergyPer().."% ")
  732. end
  733.  
  734. mon.setCursorPos(2,3)
  735. mon.setBackgroundColor(colors.green)
  736. for i=0 ,getEnergyPer(),5 do
  737. mon.write(" ")
  738. end
  739.  
  740. mon.setBackgroundColor(colors.lightGray)
  741. local tmpEn = getEnergyPer()/5
  742. local pos = 22-(19-tmpEn)
  743. mon.setCursorPos(pos,3)
  744. for i=0,(19-tmpEn),1 do
  745. mon.write(" ")
  746. end
  747.  
  748. local rfGen = 0
  749. for i=0,amountTurbines,1 do
  750. rfGen = rfGen + t[i].getEnergyProducedLastTick()
  751. end
  752.  
  753. mon.setBackgroundColor(tonumber(backgroundColor))
  754.  
  755. if lang == "de" then
  756. mon.setCursorPos(2,5)
  757. mon.write("RF-Produktion: "..math.floor(rfGen).." RF/t ")
  758. mon.setCursorPos(2,7)
  759. local fuelCons = tostring(r.getFuelConsumedLastTick())
  760. local fuelCons2 = string.sub(fuelCons, 0,4)
  761. mon.write("Reaktor-Verbrauch: "..fuelCons2.."mb/t ")
  762. mon.setCursorPos(2,9)
  763. mon.write("Rotor Geschwindigkeit: ")
  764. mon.write(math.floor(t[turbine].getRotorSpeed()))
  765. mon.setCursorPos(2,11)
  766. mon.write("Reaktor: ")
  767. mon.setCursorPos(19,20)
  768. mon.write("Modus:")
  769. mon.setCursorPos(2,13)
  770. mon.write("Aktuelle Turbine: ")
  771. elseif lang == "en" then
  772. mon.setCursorPos(2,5)
  773. mon.write("RF-Production: "..math.floor(rfGen).." RF/t ")
  774. mon.setCursorPos(2,7)
  775. local fuelCons = tostring(r.getFuelConsumedLastTick())
  776. local fuelCons2 = string.sub(fuelCons, 0,4)
  777. mon.write("Fuel Consumption: "..fuelCons2.."mb/t ")
  778. mon.setCursorPos(2,9)
  779. mon.write("Rotor Speed: ")
  780. mon.write(math.floor(t[turbine].getRotorSpeed()))
  781. mon.setCursorPos(2,11)
  782. mon.write("Reactor: ")
  783. mon.setCursorPos(19,20)
  784. mon.write("Mode:")
  785. mon.setCursorPos(2,13)
  786. mon.write("Current Turbine: ")
  787. end
  788. mon.setCursorPos(2,15)
  789. mon.write("Coils: ")
  790.  
  791. mon.setCursorPos(40,2)
  792. if lang == "de" then
  793. mon.write("Turbinen: "..(amountTurbines+1).." ")
  794. elseif lang == "en" then
  795. mon.write("Turbines: "..(amountTurbines+1).." ")
  796. end
  797.  
  798. mon.setCursorPos(2,25)
  799. mon.write("Version "..version)
  800.  
  801. lastStat = turbine
  802. end
  803.  
  804. if overallMode == "auto" then
  805. startAutoMode()
  806. elseif overallMode == "manual" then
  807. startManualMode()
  808. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement