Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin get nxZHpr0K startup
- --config
- PercentToStartTurbine = 50
- PercentToStopTurbine = 90
- MinProcentforLowMode = 75 -- means min Energycelllevel for produce over mrfneed
- MRFBuffer = 0.1 -- for produce over mrfneed (for KRF = 0. ; MRF = 1)
- xRC = 1 -- Amount of the Rotary-Condenstrator(Leave it on 1, if u dont use D-T-Fuel)
- ---===================================--Fusion-Reaktor-Proramm--v0.9.4 by Dispelnator--============================================
- --Ty for using my Mekanism-Fusion-Reactor-Programm,
- --Its my first Lua Program, so please tell me better Solutions of this Code.
- --I need help with a Function to calc the current Tritium Production
- --Means if tank on day < 50 then injection rate = tritium input then the tank goes over 75 %
- --You need minimum ProjectRed and Mekanism(+Tools,Generators)+ draconicevolution (for flux and fluid gates) for this Program
- --BundeledCable list:
- -- Red for Laser (fireup)
- -- Yellow for Alarm and Hohlraum-Insert
- -- Black 2 power laser via Tesseract/cubes...
- -- Blue for Turbine start via Water Tesseract in Boiler
- --The fuel usage is Injection-Rate/2 => For INJ-RATE = 98 you need 49 mb Tritium and 49 mb Deuterium (per tick) => ca. 9.8 MRF
- --For more Power u need Draconic Fluid-Gate and Rotary-Condenstrator*x and a Chemical Infuser (D-T-Fuel)
- --1 Rotary-Condenstrator = max 256mb/t means ca. + 25.6 MRF/t
- --Actually u can use Draconic-Energy-Core for Energy Storage but Induction-Matrix from Mekanism is better.
- --Actually u can use only Dynamic-Tanks but its the best one
- --
- --
- --Everything around the monitor I have taken from Krakaen's Big-Reactor-Program and
- --Thor_s_Crafter helped me with most buggs in the program
- --Some Videos about their Big-Reactor-Programs:
- --Krakaen : https://www.youtube.com/watch?v=SbbT7ncyS2M
- --Thor_s_Crafter: https://www.youtube.com/watch?v=XNlsU0tSHOc
- ---================================================ Edit at own Risk ===============================================================
- FirstProcent = 0
- SecondProcent = 0
- k = 0.09961964844
- InjRate = 0
- DTFuelInjRate = 0
- FuelInjRate = 0
- MRFProduce = 0
- MRFLaser = 0
- MRFMaxLaser = 0
- MRFNeed = 0
- Charge = 0
- InjRate2 = 2
- w = 0
- currentChargeLevel = 1
- currentInjRate = 1
- local TType = ""
- local EType = ""
- local ChargeStatus = "UNCHARGED"
- local ReactorStatus = "OFFLINE"
- local Auto = false
- local ChargeOn = false
- local FireUpOK = false
- local refresh = true
- local ChargeOnOffcolor = colors.green
- local FireUpcolor = colors.green
- local powerUpcolor = colors.green
- local ChargeTextcolor = colors.red
- local RectorTextcolor = colors.red
- rs.setBundledOutput("bottom", 0)
- -- tabels
- local EnergyStoragetypesMekanism = {"Basic Energy Cube", "Advanced Energy Cube", "Elite Energy Cube", "Ultimate Energy Cube" }
- local EnergyStoragetypesMekanismIM = {"Induction Matrix"}
- local button={}
- local filleds = {}
- local boxes = {}
- local lines = {}
- local texts = {}
- local GeneralBox = {}
- local ReactorBox = {}
- local MatrixBox = {}
- local GraphicBox = {}
- function initPeripherals()
- local peripheralList = peripheral.getNames()
- for i=1,#peripheralList do
- -- Reactor
- if peripheral.getType(peripheralList[i]) == "Reactor Logic Adapter" then
- FReactor = peripheral.wrap(peripheralList[i])
- end
- -- Laser Amplifier
- if peripheral.getType(peripheralList[i]) == "Laser Amplifier" then
- LaserAmp = peripheral.wrap(peripheralList[i])
- end
- -- Energystorage
- for k,v in pairs(EnergyStoragetypesMekanism) do
- if peripheral.getType(peripheralList[i]) == v then
- RFStorage = peripheral.wrap(peripheralList[i])
- EType = "mekanism"
- end
- end
- for k,v in pairs(EnergyStoragetypesMekanismIM) do
- if peripheral.getType(peripheralList[i]) == v then
- RFStorage = peripheral.wrap(peripheralList[i])
- EType = "mekanismIM"
- end
- end
- -- Monitor
- if peripheral.getType(peripheralList[i]) == "monitor" then
- mon = peripheral.wrap(peripheralList[i])
- TType = "TankInfo"
- end
- end
- end
- initPeripherals()
- term.redirect(mon)
- mon.clear()
- mon.setTextScale(0.5)
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(1,1)
- MRFLaser = LaserAmp.getEnergy()/2500000
- if MRFLaser < 400 and ChargeOn == true then
- ChargeStatus = "CHARGING"
- ChargeOnOffcolor = colors.orange
- ChargeTextcolor = colors.orange
- elseif MRFLaser < 400 and ChargeOn == false then
- ChargeStatus = "UNCHARGED"
- ChargeOnOffcolor = colors.green
- ChargeTextcolor = colors.red
- else
- ChargeStatus = "CHARGED"
- ChargeOnOffcolor = colors.gray
- ChargeTextcolor = colors.green
- end
- Power = FReactor.isIgnited()
- function recalcInj()
- InjRateMax = 98
- FuelInjRate = FReactor.getInjectionRate()
- end
- function clearTable()
- button = {}
- end
- -- All the things that make my buttons work
- function setButton(name, title, func, xmin, ymin, xmax, ymax, elem, elem2, color)
- button[name] = {}
- button[name]["title"] = title
- button[name]["func"] = func
- button[name]["active"] = false
- button[name]["xmin"] = xmin
- button[name]["ymin"] = ymin
- button[name]["xmax"] = xmax
- button[name]["ymax"] = ymax
- button[name]["color"] = color
- button[name]["elem"] = elem
- button[name]["elem2"] = elem2
- end
- -- stuff and things for buttons
- function fill(text, color, bData)
- mon.setBackgroundColor(color)
- mon.setTextColor(colors.white)
- local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
- local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(bData["title"])) /2) +1
- for j = bData["ymin"], bData["ymax"] do
- mon.setCursorPos(bData["xmin"], j)
- if j == yspot then
- for k = 0, bData["xmax"] - bData["xmin"] - string.len(bData["title"]) +1 do
- if k == xspot then
- mon.write(bData["title"])
- else
- mon.write(" ")
- end
- end
- else
- for i = bData["xmin"], bData["xmax"] do
- mon.write(" ")
- end
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- -- stuff and things for buttons
- function screen()
- local currColor
- for name,data in pairs(button) do
- local on = data["active"]
- currColor = data["color"]
- fill(name, currColor, data)
- end
- end
- -- stuff and things for buttons
- function flash(name)
- screen()
- end
- -- magical handler for clicky clicks
- function checkxy(x, y)
- for name, data in pairs(button) do
- if y>=data["ymin"] and y <= data["ymax"] then
- if x>=data["xmin"] and x<= data["xmax"] then
- data["func"](data["elem"], data["elem2"])
- flash(data['name'])
- return true
- --data["active"] = not data["active"]
- --print(name)
- end
- end
- end
- return false
- end
- -- Draw function : put's all the beautiful magic in the screen
- function draw()
- for key,value in pairs(filleds) do
- paintutils.drawFilledBox(value[1] , value[2], value[3], value[4], value[5])
- end
- for key,value in pairs(boxes) do
- paintutils.drawBox(value[1] , value[2], value[3], value[4], value[5])
- end
- for key,value in pairs(lines) do
- paintutils.drawLine(value[1] , value[2], value[3], value[4], value[5])
- end
- for key,value in pairs(texts) do
- mon.setCursorPos(value[1], value[2])
- mon.setTextColor(value[4])
- mon.setBackgroundColor(value[5])
- mon.write(value[3])
- end
- screen()
- resetDraw()
- end
- -- Resets the elements to draw to only draw the neccessity
- function resetDraw()
- filleds = {}
- boxes = {}
- lines = {}
- texts = {}
- end
- -- Handles all the clicks for the buttons
- function clickEvent()
- local myEvent={os.pullEvent("monitor_touch")}
- checkxy(myEvent[3], myEvent[4])
- end
- -- Power up the reactor (M&N are a good source of food right?)
- function powerUp(m,n)
- if FReactor.isIgnited() == false then
- Auto = true
- ChargeOn = true
- powerUpcolor = colors.green
- calcLaserAmplifier()
- else
- powerUpcolor = colors.gray
- end
- end
- -- Turns Fusion-Reactor off
- function powerDown(m,n)
- Power = false
- ChargeOn = false
- Auto = false
- rs.setBundledOutput("bottom", 0)
- calcInjRate()
- end
- function addDrawBoxes()
- local w, h = mon.getSize()
- Factor = math.floor((w/100)*2)
- GeneralBox["startX"] = 2
- GeneralBox["startY"] = 3
- GeneralBox["endX"] = ((w-(Factor*2))/3) - Factor
- GeneralBox["endY"] = (((h - (Factor*2))/3 + 1)/4)*3
- GeneralBox["height"] = GeneralBox["endY"] - GeneralBox["startY"] - (Factor*2) - 2
- GeneralBox["width"] = GeneralBox["endX"] - GeneralBox["startX"] - (Factor*2) - 2
- GeneralBox["inX"] = GeneralBox["startX"] + Factor + 1
- GeneralBox["inY"] = GeneralBox["startY"] + Factor + 1
- table.insert(boxes, {GeneralBox["startX"] , GeneralBox["startY"], GeneralBox["endX"], GeneralBox["endY"], colors.gray})
- name = "LASER"
- table.insert(lines, {GeneralBox["startX"] + Factor , GeneralBox["startY"], GeneralBox["startX"] + (Factor*2) + #name+1, GeneralBox["startY"], colors.black})
- table.insert(texts, {GeneralBox["startX"] + (Factor*2), GeneralBox["startY"], name, colors.white, colors.black})
- MatrixBox["startX"] = GeneralBox["startX"]
- MatrixBox["startY"] = (h - Factor) - ((GeneralBox["endY"] - GeneralBox["startY"])/3)*2
- MatrixBox["endX"] = GeneralBox["endX"]
- MatrixBox["endY"] = h - 1
- MatrixBox["height"] = MatrixBox["endY"] - MatrixBox["startY"] - (Factor*2) - 2
- MatrixBox["width"] = MatrixBox["endX"] - MatrixBox["startX"] - (Factor*2) - 2
- MatrixBox["inX"] = MatrixBox["startX"] + Factor + 1
- MatrixBox["inY"] = MatrixBox["startY"] + Factor + 1
- table.insert(boxes, {MatrixBox["startX"] , MatrixBox["startY"], MatrixBox["endX"], MatrixBox["endY"], colors.gray})
- name = "MATRIX"
- table.insert(lines, {MatrixBox["startX"] + Factor , MatrixBox["startY"], MatrixBox["startX"] + (Factor*2) + #name+1, MatrixBox["startY"], colors.black})
- table.insert(texts, {MatrixBox["startX"] + (Factor*2), MatrixBox["startY"], name, colors.white, colors.black})
- ReactorBox["startX"] = GeneralBox["startX"]
- ReactorBox["startY"] = GeneralBox["endY"] + Factor
- ReactorBox["endX"] = GeneralBox["endX"]
- ReactorBox["endY"] = MatrixBox["startY"] - Factor
- ReactorBox["height"] = ReactorBox["endY"] - ReactorBox["startY"] - (Factor*2) - 2
- ReactorBox["width"] = ReactorBox["endX"] - ReactorBox["startX"] - (Factor*2) - 2
- ReactorBox["inX"] = ReactorBox["startX"] + Factor + 1
- ReactorBox["inY"] = ReactorBox["startY"] + Factor + 1
- table.insert(boxes, {ReactorBox["startX"] , ReactorBox["startY"], ReactorBox["endX"], ReactorBox["endY"], colors.gray})
- name = "REACTOR"
- table.insert(lines, {ReactorBox["startX"] + Factor , ReactorBox["startY"], ReactorBox["startX"] + (Factor*2) + #name+1, ReactorBox["startY"], colors.black})
- table.insert(texts, {ReactorBox["startX"] + (Factor*2), ReactorBox["startY"], name, colors.white, colors.black})
- GraphicBox["startX"] = GeneralBox["endX"] + Factor
- GraphicBox["startY"] = GeneralBox["startY"]
- GraphicBox["endX"] = w - 2
- GraphicBox["endY"] = MatrixBox["endY"]
- GraphicBox["height"] = GraphicBox["endY"]-GraphicBox["startY"] - (Factor*2) - 2
- GraphicBox["width"] = GraphicBox["endX"]-GraphicBox["startX"] - (Factor*2) - 2
- GraphicBox["inX"] = GraphicBox["startX"] + Factor
- GraphicBox["inY"] = GraphicBox["startY"] + 2
- GraphicBox["sectionHeight"] = math.floor(GraphicBox["height"]/6)
- table.insert(boxes, {GraphicBox["startX"] , GraphicBox["startY"], GraphicBox["endX"], GraphicBox["endY"], colors.gray})
- name = "GRAPHICS/BUTTONS"
- table.insert(lines, {GraphicBox["startX"] + Factor , GraphicBox["startY"], GraphicBox["startX"] + (Factor*2) + #name+1, GraphicBox["startY"], colors.black})
- table.insert(texts, {GraphicBox["startX"] + (Factor*2), GraphicBox["startY"], name, colors.white, colors.black})
- name = "FUSION-PLANT"
- table.insert(texts, {(w/2)-(#name/2), 1, name, colors.white, colors.black})
- local names = {}
- names[1] = "CHARGE LEVEL"
- names[2] = "INJECTION RATE"
- names[3] = "ENERGY STORED"
- for i=1,5,1 do
- table.insert(texts, {GraphicBox["inX"] + Factor, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*i) +i + 1, names[i], colors.white, colors.black})
- table.insert(filleds, {GraphicBox["inX"] + Factor, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*i) +i + 2, GraphicBox["inX"] + GraphicBox["width"] - 1, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*(i+1)) +i, colors.lightGray})
- end
- refresh = true
- while refresh do
- recalcInj()
- if FReactor.isIgnited() == false then
- powerUpcolor = colors.green
- FireUpcolor = colors.green
- ReactorStatus = "OFFLINE"
- RectorTextcolor = colors.red
- else
- powerUpcolor = colors.gray
- FireUpcolor = colors.gray
- ReactorStatus = "ONLINE"
- RectorTextcolor = colors.green
- end
- setButton("CHARG","CHARGE", ChargeOnOff, GraphicBox["inX"] + Factor, GraphicBox["inY"] + 1, GraphicBox["inX"] + (GraphicBox["width"]/4 - 1), GraphicBox["inY"] + 3, 0, 0, ChargeOnOffcolor)
- setButton("START INJ","START INJ", FireUp, GraphicBox["inX"] + (GraphicBox["width"]/4 + Factor - 1), GraphicBox["inY"] + 1, GraphicBox["inX"] + ((GraphicBox["width"]/4)*2 - 1) , GraphicBox["inY"] + 3,0, 0, FireUpcolor)
- setButton("AUTO-CHARGE","AUTO-CHARGE", powerUp, GraphicBox["inX"] + ((GraphicBox["width"]/4)*2 + Factor - 1), GraphicBox["inY"] + 1, GraphicBox["inX"] + ((GraphicBox["width"]/4)*3 - 1), GraphicBox["inY"] + 3,0, 0, powerUpcolor)
- setButton("SHUT-DOWN","SHUT-DOWN", powerDown, GraphicBox["inX"] + ((GraphicBox["width"]/4)*3 + Factor - 1), GraphicBox["inY"] + 1, GraphicBox["inX"] + (GraphicBox["width"] - 1), GraphicBox["inY"] + 3,0, 0, colors.red)
- if FireUpOK == true then
- sleep(10)
- rs.setBundledOutput("bottom",colors.subtract(rs.getBundledOutput("bottom"), colors.yellow))
- if FReactor.isIgnited() == false then
- rs.setBundledOutput("bottom", colors.red, 1)
- sleep(1)
- rs.setBundledOutput("bottom", 0, colors.red)
- end
- FireUpOK = false
- end
- if RFStoragePercent ~= nil then
- if RFStoragePercent < PercentToStartTurbine then
- rs.setBundledOutput("bottom", colors.blue, 1)
- elseif RFStoragePercent > PercentToStopTurbine then
- rs.setBundledOutput("bottom", 0, colors.blue)
- end
- end
- parallel.waitForAny(refreshStats, loop, clickEvent)
- end
- end
- function loop()
- while true do
- calcInjRate()
- end
- end
- function refreshStats()
- calcInjRate()
- calcLaserAmplifier()
- -- Laser Visualisierung
- local i = 1
- local infotoAdd = "STATUS: "
- local infotoAdd1 = "CHARGE-LEVEL: "
- if currentChargeLevel ~= MRFLaser then
- currentChargeLevel = MRFLaser
- if MRFLaser > 400 then
- MRFLaserT = 400
- else
- MRFLaserT = MRFLaser
- end
- MRFLaserText = math.floor((MRFLaserT/400)*100)
- table.insert(lines, {GeneralBox["inX"] , GeneralBox["inY"],GeneralBox["inX"] + GeneralBox["width"] , GeneralBox["inY"], colors.black})
- table.insert(texts, {GeneralBox["inX"] + 1, GeneralBox["inY"] - 1, infotoAdd, colors.white, colors.black})
- table.insert(texts, {GeneralBox["inX"] + 1 + #infotoAdd, GeneralBox["inY"] - 1, ChargeStatus .. " ", ChargeTextcolor, colors.black})
- table.insert(texts, {GeneralBox["inX"] + 1 , GeneralBox["inY"] + Factor - 1, infotoAdd1 .. MRFLaserText .. "% ", colors.white, colors.black})
- table.insert(filleds, {GraphicBox["inX"] + Factor, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*i) + i + 2, GraphicBox["inX"] + GraphicBox["width"] - 1, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*(i+1)) +i, colors.lightGray})
- width = math.floor((GraphicBox["width"] / 400)*MRFLaserT)
- table.insert(filleds, {GraphicBox["inX"] + Factor, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*i) +i + 2, GraphicBox["inX"] + width - 1, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*(i+1)) +i, colors.green})
- end
- -- Reactor Visualisierung
- local i = 2
- local infotoAdd = "STATUS: "
- local infotoAdd1 = "INJ-RATE: "
- local infotoAdd2 = "PLASMA-HEAT: "
- local infotoAdd3 = "CASE-HEAT: "
- local infotoAdd4 = "ENERGY/T: "
- local infotoAdd5 = "ENERGYSTORAGE: "
- local infotoAdd6 = "WATER: "
- local infotoAdd7 = "STEAM: "
- local infotoAdd8 = "INPUT: "
- if InjRateText > (xRC*256+98) then
- InjRateT = (xRC*256+98)
- else
- InjRateT = InjRateText
- end
- if RFMaxStorageT == nil then
- RFMaxStorageT = 0
- end
- if RFStoragedT == nil then
- RFStoragedT = 0
- end
- if MRFInputT == nil then
- MRFInputT = 0
- end
- table.insert(lines, {ReactorBox["inX"] , ReactorBox["inY"],ReactorBox["inX"] + ReactorBox["width"] , ReactorBox["inY"], colors.black})
- table.insert(texts, {ReactorBox["inX"] + 1, ReactorBox["inY"] - 1, infotoAdd, colors.white, colors.black})
- table.insert(texts, {ReactorBox["inX"] + 1 + #infotoAdd, ReactorBox["inY"] - 1, ReactorStatus .. " ", RectorTextcolor, colors.black})
- table.insert(texts, {ReactorBox["inX"] + 1 , ReactorBox["inY"] + Factor - 1, infotoAdd1 .. InjRateT .. " ", colors.white, colors.black})
- table.insert(texts, {ReactorBox["inX"] + 1 , ReactorBox["inY"] + 2*Factor - 1, infotoAdd2 .. PlasmaHeat .. " GK ", colors.white, colors.black})
- table.insert(texts, {ReactorBox["inX"] + 1 , ReactorBox["inY"] + 3*Factor - 1, infotoAdd3 .. CaseHeat .. " GK ", colors.white, colors.black})
- table.insert(texts, {ReactorBox["inX"] + 1 , ReactorBox["inY"] + 4*Factor - 1, infotoAdd4 .. RFOutputT .. " MRF/t ", colors.white, colors.black})
- table.insert(texts, {ReactorBox["inX"] + 1 , ReactorBox["inY"] + 5*Factor - 1, infotoAdd5 .. RFStoragePercent .. "% ", colors.white, colors.black})
- table.insert(texts, {ReactorBox["inX"] + 1 , ReactorBox["inY"] + 6*Factor - 1, infotoAdd6 .. "--- ", colors.white, colors.black})
- table.insert(texts, {ReactorBox["inX"] + 1 , ReactorBox["inY"] + 7*Factor - 1, infotoAdd7 .. "--- ", colors.white, colors.black})
- table.insert(filleds, {GraphicBox["inX"] + Factor, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*i) +i + 2, GraphicBox["inX"] + GraphicBox["width"] - 1, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*(i+1)) +i, colors.lightGray})
- width = math.floor((GraphicBox["width"] / InjRateMax)*InjRateT)
- table.insert(filleds, {GraphicBox["inX"] + Factor, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*i) +i + 2, GraphicBox["inX"] + width - 1, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*(i+1)) +i, colors.green})
- local i = 3
- table.insert(filleds, {GraphicBox["inX"] + Factor, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*i) +i + 2, GraphicBox["inX"] + GraphicBox["width"] - 1, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*(i+1)) +i, colors.lightGray})
- width = math.floor(GraphicBox["width"]*(RFStoragePercent/100))
- table.insert(filleds, {GraphicBox["inX"] + Factor, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*i) +i + 2, GraphicBox["inX"] + width - 1, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*(i+1)) +i, colors.green})
- -- Tank Visualisierung
- local i = 4
- local infotoAdd = " : "
- table.insert(lines, {MatrixBox["inX"] , MatrixBox["inY"],MatrixBox["inX"] + MatrixBox["width"] , MatrixBox["inY"], colors.black})
- table.insert(texts, {MatrixBox["inX"] + 1, MatrixBox["inY"] - 1, RFStoragedT .. " / " .. RFMaxStorageT .. " TRF ", colors.white, colors.black})
- table.insert(texts, {MatrixBox["inX"] + 1, MatrixBox["inY"] + Factor - 1, infotoAdd8 .. MRFInputT .. " MRF/t ", colors.white, colors.black})
- draw()
- sleep(1)
- end
- -- Calcs and Sets Inj Rate
- function calcInjRate()
- recalcInj()
- calcMRFProduce()
- if(Power == true) then
- InjRate = 2
- FuelInjRate = 2
- InjRateMax = 98
- else
- FuelInjRate = 0
- end
- InjRateText = FuelInjRate
- --FReactor.setInjectionRate(FuelInjRate)
- if FReactor.getProducing() ~= "Unformed." then
- RFOutputT = round((FReactor.getProducing()/2500000), 1)
- PlasmaHeat = round((FReactor.getPlasmaHeat()/1000000000), 1)
- CaseHeat = round((FReactor.getCaseHeat()/1000000000), 1)
- else
- RFOutputT = 0
- PlasmaHeat = 0
- CaseHeat = 0
- end
- sleep(1)
- end
- -- Calcs MRFProduce
- function calcMRFProduce()
- if EType == "mekanism" then
- local MRFNeed = RFStorage.getOutput()/2500000
- RFStoraged = RFStorage.getEnergy()/2500000
- RFMaxStorage = RFStorage.getMaxEnergy()/2500000
- RFStoragePercent = math.floor(RFStoraged / RFMaxStorage * 100)
- if RFStoragePercent > MinProcentforLowMode then
- MRFProduce = MRFNeed + MRFBuffer -- LowRF Mode but everytime over RFOutput
- else
- MRFProduce = RFMaxStorage -- MaxRF Mode
- end
- end
- if EType == "mekanismIM" then
- if RFStorage.getOutput() ~= "Unformed." then
- local MRFNeed = RFStorage.getOutput()/2500000
- MRFInputT = round(RFStorage.getInput()/2500000, 1)
- RFStoraged = RFStorage.getEnergy()/2500000
- RFStoragedT = round(RFStoraged/1000000, 1)
- RFMaxStorage = RFStorage.getMaxEnergy()/2500000
- RFMaxStorageT = round(RFMaxStorage/1000000, 1)
- RFMaxTransfer = RFStorage.getTransferCap()/2500000
- RFStoragePercent = math.floor(RFStoraged / RFMaxStorage * 100)
- if RFStoragePercent > MinProcentforLowMode then
- MRFProduce = MRFNeed + MRFBuffer -- LowRF Mode but everytime over RF...
- else
- MRFProduce = RFMaxTransfer -- MaxRF Mode
- end
- else
- MRFInputT = 0
- RFStoragedT = 0
- RFMaxStorageT = 0
- RFStoragePercent = 0
- MRFProduce = 0
- end
- end
- end
- -- Laser Amplifier
- function calcLaserAmplifier()
- MRFMaxLaser = LaserAmp.getMaxEnergy()/2500000
- MRFLaser = LaserAmp.getEnergy()/2500000
- if MRFLaser < 400 and ChargeOn == true then
- Charge = 10000000
- ChargeStatus = "CHARGING"
- ChargeOnOffcolor = colors.orange
- ChargeTextcolor = colors.orange
- elseif MRFLaser < 400 and ChargeOn == false then
- Charge = 0
- ChargeStatus = "UNCHARGED"
- ChargeOnOffcolor = colors.green
- ChargeTextcolor = colors.red
- else
- Charge = 0
- ChargeStatus = "CHARGED"
- ChargeOnOffcolor = colors.gray
- ChargeTextcolor = colors.green
- end
- if MRFLaser < 400 then
- rs.setBundledOutput("bottom",colors.combine(rs.getBundledOutput("bottom"), colors.black))
- end
- if MRFLaser >= 400 then
- if Auto == true then
- FReactor.setInjectionRate(2)
- FireUp()
- end
- end
- end
- -- Alarm + Hohlraum insert
- function FireUp()
- if FReactor.isIgnited() == false then
- Auto = false
- Power = true
- FireUpOK = true
- FReactor.setInjectionRate(2)
- rs.setBundledOutput("bottom",colors.combine(rs.getBundledOutput("bottom"), colors.yellow))
- FireUpcolor = colors.green
- calcInjRate()
- else
- FireUpcolor = colors.gray
- end
- end
- function ChargeOnOff()
- ChargeOn = true
- calcLaserAmplifier()
- end
- --============================================================
- -- add comma to separate thousands
- -- From Lua-users.org/wiki/FormattingNumbers
- --
- --
- function comma_value(amount)
- local formatted = amount
- while true do
- formatted, zz = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (zz==0) then
- break
- end
- end
- return formatted
- end
- ---============================================================
- -- rounds a number to the nearest decimal places
- -- From Lua-users.org/wiki/FormattingNumbers
- --
- --
- function round(val, decimal)
- if (decimal) then
- return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
- else
- return math.floor(val+0.5)
- end
- end
- --===================================================================
- -- given a numeric value formats output with comma to separate thousands
- -- and rounded to given decimal places
- -- From Lua-users.org/wiki/FormattingNumbers
- --
- function format_num(amount, decimal, prefix, neg_prefix)
- local str_amount, formatted, famount, remain
- decimal = decimal or 2 -- default 2 decimal places
- neg_prefix = neg_prefix or "-" -- default negative sign
- famount = math.abs(round(amount,decimal))
- famount = math.floor(famount)
- remain = round(math.abs(amount) - famount, decimal)
- -- comma to separate the thousands
- formatted = comma_value(famount)
- -- attach the decimal portion
- if (decimal > 0) then
- remain = string.sub(tostring(remain),3)
- formatted = formatted .. "." .. remain ..
- string.rep("0", decimal - string.len(remain))
- end
- -- attach prefix string e.g '$'
- formatted = (prefix or "") .. formatted
- -- if value is negative then format accordingly
- if (amount<0) then
- if (neg_prefix=="()") then
- formatted = "("..formatted ..")"
- else
- formatted = neg_prefix .. formatted
- end
- end
- return formatted
- end
- addDrawBoxes()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement