Advertisement
EatMyNoodle

turbineControl

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