Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local uk = "unknown"
- local p = peripheral
- local cname = "cofh_thermalexpansion_energycell_"
- local mname = "monitor_"
- local sm = " "
- local k = 0 --X
- local l = 0 --X
- local m = 0 --X
- local n = 0 --X
- local o = 0 --X
- local q = 0 --X
- local r = 0
- local s = 0
- local UHSLC = 0
- local num = 0
- local energy = 0
- local maxenergy = 0
- local monitors = {}
- local cells = {}
- local numbers = {}
- local timeINNum = 0
- local midnum = 0
- local cme = 0
- local ce = 0
- local mx = 0
- local inStartNum
- local inSumNum
- local inIDNum
- --local writeISNfile = fs.open("inSumNum","w")
- --local readISNfile = fs.open("inSumNum","r")
- --local writeIIDNfile = fs.open("inIDNum","w")
- --local readIIDNfile = fs.open("inIDNum","r")
- --local writeTINNfile = fs.open("timeINNum","w")
- --local readTINNfile = fs.open("timeINNum","r")
- --local writeCELLSfile = fs.open("CELLS","w")
- --local readCELLSfile = fs.open("CELLS","r")
- --local fileDataISN={}
- --local fileDataIIDN={}
- --local fileDataTINN={}
- --local fileDataCELLS={}
- --local ISNLine = readISNfile.readLine()
- --local IIDNLine = readIIDNfile.readLine()
- --local TINNLine = readIIDNfile.readLine()
- --local CELLSLine = readCELLSfile.readLine()
- function initNumArray()
- for i=0,500 do
- numbers[i+1]=i
- end
- end
- function configMonitor()
- term.clear()
- term.setCursorPos(1,1)
- local mid = 0
- print("Bitte gebe die aktive(!) Rednet-ID des 3x2 (bxl) Monitors ein!")
- print("Bitte beachte, dass das Programm abstürzt, wenn es keine Zahl erhält!")
- mid = read()
- mx = mid+midnum
- mon = p.wrap(mname..tonumber(mx))
- end
- function configCells()
- while l==0 do
- term.clear()
- term.setCursorPos(1,1)
- local cin = ""
- local inStart = ""
- --local inSum = ""
- --local inID = ""
- print("Willst du den automatischen oder den manuellen Modus für die Konfiguration deiner")
- print("Energiezellen benutzen?")
- print("Fuer den automatischen Modus, gebe 'auto' ein")
- print("Fuer den manuellen Modus, gebe 'manu' ein")
- print("Bitte beachte beim automatischen Modus, dass die IDs nacheinander folgen! (Wie z.B.: 1,2,3,4,5,...)")
- print("(Der autom. Modus ist einfacher, der manuelle Modus ist auch nicht schlecht!)")
- print("HINWEIS: Dieses Programm ist für die Energiezellen von Thermal Expansion 4 geschrieben worden!")
- print("(Für PROs: Das bedeutet, dass für dieses Programm die Standardbezeichnung")
- print("'cofh_thermalexpansion_energycell_' benutzt wird!)")
- cin = read()
- if cin=="auto" then
- l=1
- term.clear()
- term.setCursorPos(1,1)
- print("Du hast den automatischen Modus gewaehlt")
- os.sleep(1)
- print("Gebe nun die niedrigste ID deiner Energiezellen ein!")
- inStart = read()
- local writeIStNfile = fs.open("inStartNum","w")
- writeIStNfile.writeLine(inStart)
- writeIStNfile.close()
- inStartNum = tonumber(inStart)
- os.sleep(1)
- print("Gebe nun die Gesamtanzahl deiner Energiezellen ein!")
- local inSum = read()
- local writeISNfile = fs.open("inSumNum","w")
- writeISNfile.writeLine(inSum)
- writeISNfile.close()
- for i=0,500 do
- if tonumber(inSum)==numbers[i+1] then
- inSumNum=numbers[i+1]
- end
- end
- --inSumNum = tonumber(inSum)
- os.sleep(1)
- print("Energiezellen werden nun konfiguriert...")
- --local CELLSLine = writeCELLSfile.writeLine()
- local writeCELLSfile = fs.open("CELLS","w")
- for i=1,inSumNum do
- x=inStartNum+inSumNum
- cells[i] = peripheral.wrap(cname..x)
- print("Energiezelle 'c"..(i).."' wurde erfolgreich konfiguriert!")
- end
- --ct = textutils.serialize(cells)
- writeCELLSfile.write(cells)
- --repeat
- --table.insert(cells,CELLSLine)
- --CELLSLine = writeCELLSfile.writeLine()
- --until CELLSLine == nil
- writeCELLSfile.close()
- os.sleep(1)
- print("Energiezellen sind nun konfiguriert!")
- else
- if cin=="manu" then
- l=1
- term.clear()
- term.setCursorPos(1,1)
- print("Du hast den manuellen Modus gewaehlt")
- os.sleep(1)
- print("Gebe nun die Gesamtanzahl deiner Energiezellen ein!")
- local inSum = read()
- local writeISNfile = fs.open("inSumNum","w")
- writeISNfile.writeLine(inSum)
- writeISNfile.close()
- for i=0,500 do
- if tonumber(inSum)==numbers[i+1] then
- inSumNum=numbers[i+1]
- end
- end
- --inSumNum = tonumber(inSum)
- print("Gebe nun die(/alle) ID(s) deiner Energiezelle(n) nacheinander ein!")
- for i=1,inSumNum do
- local inID = read()
- local writeIIDNfile = fs.open("inIDNum","w")
- writeIIDNfile.writeLine(inID)
- writeIIDNfile.close()
- for i=0,500 do
- if tonumber(inID)==numbers[i+1] then
- inIDNum = numbers[i+1]
- end
- end
- --inIDNum = tonumber(inID)
- cells[i] = p.wrap(cname..inIDNum)
- print("Energiezelle 'c"..i.."' wurde erfolgreich konfiguriert!")
- end
- else
- l=0
- print(cin.." gibt es nicht!")
- end
- end
- end
- end
- function configComputer()
- while m==0 do
- term.clear()
- term.setCursorPos(1,1)
- local sideRN = ""
- print("Dein Computer wird jetzt fuer Rednet konfiguriert!")
- print("Gebe nun ein, an welcher Seite des PCs das (wireless) Modem für Rednet angeschlossen ist!")
- print("Verfuegbare Seiten: oben('top'), unten('bottom'), rechts('right'), links('left'), hinten('back')")
- print("Bitte beachte, dass das Programm abstuerzt, wenn an der angegebenen Seite kein Modem angeschlossen ist!")
- sideRN = read()
- if sideRN == "top" or sideRN == "bottom" or sideRN == "right" or sideRN == "left" or sideRN == "back" then
- rednet.open(sideRN)
- m=1
- else
- print(sideRN.." -Eingabe nicht akzeptabel!")
- m=0
- end
- end
- while n==0 do
- term.clear()
- term.setCursorPos(1,1)
- --local timeIN = ""
- print("Gebe nun die Zeit in Sekunden ein, wie oft der Computer die Daten der Energiezelle(n) abfragen soll!")
- print("0 ist nicht akzeptabel! Wenn du bspw. jede halbe Sekunde haben willst, dann gebe '0.5' ein!")
- local timeIN = read()
- local writeTINNfile = fs.open("timeINNum","w")
- writeTINNfile.writeLine(timeIN)
- writeTINNfile.close()
- for i=0,500 do
- if tonumber(timeIN)==numbers[i+1] then
- timeINNum = numbers[i+1]
- end
- end
- --timeINNum = tonumber(timeIN)
- if tonumber(timeIN)==0 then
- print("Bist du eigentlich behindert? Ich hab doch gesagt, dass '"..timeINNum.."' nicht akzeptiert wird -.-")
- n=0
- else
- print("Updateintervall wurde erfolgreich auf '"..timeINNum.."'s gesetzt")
- n=1
- end
- end
- end
- function setupMonitor()
- mon.setBackgroundColor(colors.lime)
- mon.setTextColor(colors.blue)
- for i=0,20 do
- mon.setCursorPos(1,i+1)
- mon.write(sm)
- end
- mon.setCursorPos(1,1)
- mon.write(" ENERGIE-MONITOR"..sm)
- end
- function readEnergy()
- ce = 0
- cme = 0
- local readISNfile = fs.open("inSumNum","r")
- local readIStNfile = fs.open("inStartNum","r")
- --local readCELLSfile = fs.open("CELLS","r")
- local fileDataISN={}
- local fileDataIStN={}
- --local fileDataCELLS={}
- local ISNLine = readISNfile.readLine()
- local IStNLine = readIStNfile.readLine()
- --local CELLSLine = readCELLSfile.readLine()
- repeat
- table.insert(fileDataISN,ISNLine)
- ISNLine = readISNfile.readLine()
- until ISNLine == nil
- repeat
- table.insert(fileDataIStN,IStNLine)
- IStNLine = readIStNfile.readLine()
- until IStNLine == nil
- --repeat
- --table.insert(fileDataCELLS,CELLSLine)
- --CELLSLine = readCELLSfile.readLine()
- --until CELLSLine == nil
- --cells = textutils.unserialize(fileDataCELLS.readAll())
- for i=1,(tonumber(fileDataISN[1])+0) do
- --local e = 0
- --local me = 0
- cells = {}
- cells[i] = peripheral.wrap(tostring(cname..(fileDataIStN[1]+0)))
- energy = cells[i].getEnergyStored("unknown")
- maxenergy = cells[i].getMaxEnergyStored("unknown")
- ce = ce+energy
- cme = cme+maxenergy
- end
- readISNfile.close()
- readIStNfile.close()
- --readCELLSfile.close()
- end
- function writeEnergy()
- local readTINNfile = fs.open("timeINNum","r")
- local fileDataTINN={}
- local TINNLine = readTINNfile.readLine()
- repeat
- table.insert(fileDataTINN,TINNLine)
- TINNLine = readTINNfile.readLine()
- until TINNLine == nil
- readTINNfile.close()
- mon.setCursorPos(1,2)
- mon.clearLine()
- mon.write("Energie: "..ce.."RF"..sm)
- mon.setCursorPos(1,3)
- local cen = ce
- if cen>ceo then
- mon.clearLine()
- mon.write("Energiegewinn seit letztem"..sm)
- mon.setCursorPos(1,4)
- mon.clearLine()
- mon.write("Check ("..fileDataTINN[1].."s): +"..cen-ceo.."RF"..sm)
- else
- if cen==ceo then
- mon.clearLine()
- mon.write("Gleicher Energiestand"..sm)
- mon.setCursorPos(1,4)
- mon.clearLine()
- mon.write(sm)
- else
- if c13n<c13o then
- mon.clearLine()
- mon.write("Energieverlust seit letztem"..sm)
- mon.setCursorPos(1,4)
- mon.clearLine()
- mon.write("Check ("..fileDataTINN[1].."s): -"..ceo-cen.."RF"..sm)
- end
- end
- end
- local ep = cen/cme*100
- mon.setCursorPos(1,6)
- mon.clearLine()
- mon.write(" (in '%'):"..sm)
- mon.setCursorPos(1,7)
- mon.clearLine()
- mon.write(ep.."%"..sm)
- end
- function calcEnergyA()
- if o==0 then
- ceo=0
- o=1
- end
- end
- function calcEnergyB()
- ceo = 0
- local readISNfile = fs.open("inSumNum","r")
- local readIStNfile = fs.open("inStartNum","r")
- --local readCELLSfile = fs.open("CELLS","r")
- local fileDataISN={}
- local fileDataIStN={}
- --local fileDataCELLS={}
- local ISNLine = readISNfile.readLine()
- local IStNLine = readIStNfile.readLine()
- --local CELLSLine = readCELLSfile.readLine()
- repeat
- table.insert(fileDataISN,ISNLine)
- ISNLine = readISNfile.readLine()
- until ISNLine == nil
- repeat
- table.insert(fileDataIStN,IStNLine)
- IStNLine = readIStNfile.readLine()
- until IStNLine == nil
- --repeat
- --table.insert(fileDataCELLS,CELLSLine)
- --CELLSLine = readCELLSfile.readLine()
- --until CELLSLine == nil
- --cells = textutils.unserialize(fileDataCELLS.readAll())
- for i=1,(tonumber(fileDataISN[1])+0) do
- local eo = 0
- cells = {}
- cells[i] = peripheral.wrap(tostring(cname..(fileDataIStN[1]+0)))
- eo = cells[i].getEnergyStored("unknown")
- ceo = ceo+eo
- end
- readISNfile.close()
- readIStNfile.close()
- --readCELLSfile.close()
- end
- function rednetListener()
- end
- while true do
- if k==0 then
- initNumArray()
- configComputer()
- configMonitor()
- configCells()
- k=1
- end
- if q==0 then
- setupMonitor()
- q=1
- end
- calcEnergyA()
- readEnergy()
- writeEnergy()
- calcEnergyB()
- rednetListener()
- local readTINNfile = fs.open("timeINNum","r")
- local fileDataTINN={}
- local TINNLine = readTINNfile.readLine()
- repeat
- table.insert(fileDataTINN,TINNLine)
- TINNLine = readTINNfile.readLine()
- until TINNLine == nil
- os.sleep(tonumber((fileDataTINN[1]+0)))
- readTINNfile.close()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement