Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --config
- MinProcenttoBoost = 10 -- means min Tank amount vor max Inj Rate
- MinProcentforLowMode = 75 -- means min Energycelllevel for produce over mrfneed
- MRFBuffer = 0.2 -- for produce over mrfneed (for KRF = 0. ; MRF = 1)
- ---=================================== Don't edit anything =================================================
- FirstProcent = 0
- SecondProcent = 0
- k = 0.09961964844
- InjRate = 0
- DTFuelInjRate = 0
- FuelInjRate = 0
- MRFProduce = 0
- amountTanks = 0
- MRFLaser = 0
- MRFMaxLaser = 0
- Charge = 0
- InjRate2 = 2
- currentChargeLevel = 1
- currentInjRate = 1
- local TType = ""
- local EType = ""
- local ChargeStatus = "UNCHARGED"
- local ReactorStatus = "OFFLINE"
- local TankLevel = false
- local DraconicFluidGate = false
- local DraconicFluxGate = false
- local Rain = false
- local Day = true
- 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("back", 0)
- -- tabels
- local Tanktypes = {"dynamic_tank"}
- local EnergyStoragetypesMekanism = {"Basic Energy Cube", "Advanced Energy Cube", "Elite Energy Cube", "Ultimate Energy Cube" }
- local EnergyStoragetypesMekanismIM = {"Induction Matrix"}
- local EnergyStoragetypesDraconic = {"draconic_rf_storage"}
- local Tanks = {}
- local button={}
- local filleds = {}
- local boxes = {}
- local lines = {}
- local texts = {}
- local GeneralBox = {}
- local ReactorBox = {}
- local TankBox = {}
- 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])
- write(i.."= ".. peripheralList[i])
- print(" ")
- end
- -- Laser Amplifier
- if peripheral.getType(peripheralList[i]) == "Laser Amplifier" then
- LaserAmp = peripheral.wrap(peripheralList[i])
- write(i.."= ".. peripheralList[i])
- print(" ")
- end
- -- Fluid-Gate
- if peripheral.getType(peripheralList[i]) == "fluid_gate" then
- DTFuelInj = peripheral.wrap(peripheralList[i])
- write(i.."= ".. peripheralList[i])
- print(" ")
- DraconicFluidGate = true
- end
- -- Flux-Gate
- if peripheral.getType(peripheralList[i]) == "flux_gate" then
- FluxGate = peripheral.wrap(peripheralList[i])
- write(i.."= ".. peripheralList[i])
- print(" ")
- DraconicFluxGate = true
- end
- -- Energystorage
- for k,v in pairs(EnergyStoragetypesMekanism) do
- if peripheral.getType(peripheralList[i]) == v then
- RFStorage = peripheral.wrap(peripheralList[i])
- EType = "mekanism"
- write(i.."= ".. peripheralList[i])
- print(" ")
- end
- end
- for k,v in pairs(EnergyStoragetypesMekanismIM) do
- if peripheral.getType(peripheralList[i]) == v then
- RFStorage = peripheral.wrap(peripheralList[i])
- EType = "mekanismIM"
- write(i.."= ".. peripheralList[i])
- print(" ")
- end
- end
- for k,v in pairs(EnergyStoragetypesDraconic) do
- if peripheral.getType(peripheralList[i]) == v then
- RFStorage = peripheral.wrap(peripheralList[i])
- EType = "draconic"
- write(i.."= ".. peripheralList[i])
- print(" ")
- end
- end
- -- Monitor
- if peripheral.getType(peripheralList[i]) == "monitor" then
- mon = peripheral.wrap(peripheralList[i])
- TType = "TankInfo"
- write(i.."= ".. peripheralList[i])
- print(" ")
- end
- -- Tanks
- for k,v in pairs(Tanktypes) do
- if peripheral.getType(peripheralList[i]) == v then
- Tanks[amountTanks]=peripheral.wrap(peripheralList[i])
- amountTanks = amountTanks + 1
- write(i.."= ".. peripheralList[i])
- print(" ")
- end
- end
- -- Pipes
- FirstPipe = peripheral.wrap("right")
- SecondPipe = peripheral.wrap("left")
- end
- amountTanks = amountTanks - 1
- 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
- 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
- -- Don't question my code, it works on my machine...
- function label(w, h, text)
- mon.setCursorPos(w, h)
- mon.write(text)
- 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("back", 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})
- TankBox["startX"] = GeneralBox["startX"]
- TankBox["startY"] = (h - Factor) - ((GeneralBox["endY"] - GeneralBox["startY"])/3)*2
- TankBox["endX"] = GeneralBox["endX"]
- TankBox["endY"] = h - 1
- TankBox["height"] = TankBox["endY"] - TankBox["startY"] - (Factor*2) - 2
- TankBox["width"] = TankBox["endX"] - TankBox["startX"] - (Factor*2) - 2
- TankBox["inX"] = TankBox["startX"] + Factor + 1
- TankBox["inY"] = TankBox["startY"] + Factor + 1
- table.insert(boxes, {TankBox["startX"] , TankBox["startY"], TankBox["endX"], TankBox["endY"], colors.gray})
- name = "TANKS"
- table.insert(lines, {TankBox["startX"] + Factor , TankBox["startY"], TankBox["startX"] + (Factor*2) + #name+1, TankBox["startY"], colors.black})
- table.insert(texts, {TankBox["startX"] + (Factor*2), TankBox["startY"], name, colors.white, colors.black})
- ReactorBox["startX"] = GeneralBox["startX"]
- ReactorBox["startY"] = GeneralBox["endY"] + Factor
- ReactorBox["endX"] = GeneralBox["endX"]
- ReactorBox["endY"] = TankBox["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"] = TankBox["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
- if FReactor.isIgnited() == false then
- powerUpcolor = colors.green
- else
- powerUpcolor = colors.gray
- 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("back", 1, colors.yellow)
- if FReactor.isIgnited() == false then
- rs.setBundledOutput("back", colors.red, 1)
- sleep(1)
- rs.setBundledOutput("back", 1, colors.red)
- end
- FireUpOK = false
- end
- parallel.waitForAny(refreshStats, clickEvent)
- end
- end
- function refreshStats()
- RedstoneSignal()
- 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: "
- if InjRateText > 354 then
- InjRateT = 354
- else
- InjRateT = InjRateText
- end
- InjRateText = math.floor((InjRateT/354)*100)
- 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 ", 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"] / 354)*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, {TankBox["inX"] , TankBox["inY"],TankBox["inX"] + TankBox["width"] , TankBox["inY"], colors.black})
- table.insert(texts, {TankBox["inX"] + 1, TankBox["inY"] - 1, FirstTankText .. infotoAdd .. FirstProcent .."% ", colors.white, colors.black})
- table.insert(texts, {TankBox["inX"] + 1, TankBox["inY"] + Factor - 1, SecondTankText .. infotoAdd .. SecondProcent .. "% ", colors.white, colors.black})
- table.insert(texts, {GraphicBox["inX"] + Factor, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*i) +i + 1, FirstTankName, 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"]*(FirstProcent/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, FirstTankcolor})
- local i = 5
- table.insert(texts, {GraphicBox["inX"] + Factor, GraphicBox["inY"] + (GraphicBox["sectionHeight"]*i) +i + 1, SecondTankName, 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"]*(SecondProcent/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, SecondTankcolor})
- draw()
- sleep(1)
- end
- if DraconicFluidGate == true then
- DTFuelInj.setOverrideEnabled(true)
- end
- if DraconicFluxGate == true then
- FluxGate.setOverrideEnabled(true)
- 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
- local MRFNeed = RFStorage.getOutput()/2500000
- RFStoraged = RFStorage.getEnergy()/2500000
- RFMaxStorage = RFStorage.getMaxEnergy()/2500000
- RFMaxTransfer = RFStorage.getTransferCap()/2500000
- RFStoragePercent = math.floor(RFStoraged / RFMaxStorage * 100)
- if RFStoragePercent > MinProcentforLowMode then
- MRFProduce = MRFNeed + MRFBuffer -- LowRF Mode but everytime over RFOutput
- else
- MRFProduce = RFMaxTransfer -- MaxRF Mode
- end
- end
- if EType == "draconic" then
- RFStoraged = RFStorage.getEnergyStored()/1000000
- RFMaxStorage = RFStorage.getMaxEnergyStored()/1000000
- RFStoragePercent = math.floor(RFStoraged / RFMaxStorage * 100)
- local MRFNeed = RFMaxStorage - RFStoraged
- MRFProduce = MRFNeed + MRFBuffer
- end
- end
- -- Stats of Tanks
- function calcTankStats()
- local FirstTankInfo = Tanks[0].getTankInfo()
- local FirstTankStats = FirstTankInfo[1]
- if FirstTankStats.contents == nil then
- FirstTankName = "No Fluid"
- else
- local FirstCapacity = FirstTankStats["capacity"]
- FirstTankName = FirstTankStats["contents"]["rawName"]
- FirstTankLiquid = FirstTankStats["contents"]["name"]
- FirstAmount = FirstTankStats["contents"]["amount"]
- FirstProcent = math.floor(FirstAmount / FirstCapacity * 100)
- end
- local SecondTankInfo = Tanks[1].getTankInfo()
- local SecondTankStats = SecondTankInfo[1]
- if SecondTankStats.contents == nil then
- SecondTankName = "No Fluid"
- else
- local SecondCapacity = SecondTankStats["capacity"]
- SecondTankName = SecondTankStats["contents"]["rawName"]
- SecondTankLiquid = SecondTankStats["contents"]["name"]
- SecondAmount = SecondTankStats["contents"]["amount"]
- SecondProcent = math.floor(SecondAmount / SecondCapacity * 100)
- end
- if FirstTankName == "Liquid Tritium" then
- FirstTankcolor = colors.cyan
- FirstTankText = "L.Tritium"
- SecondTankcolor = colors.red
- SecondTankText = "L.Deuterium"
- else
- FirstTankcolor = colors.red
- FirstTankText = "L.Deuterium"
- SecondTankcolor = colors.cyan
- SecondTankText = "L.Tritium"
- end
- end
- -- Calcs and Sets Inj Rate
- function calcInjRate()
- calcMRFProduce()
- calcTankStats()
- calcPipeStats()
- InjRate1 = math.ceil(MRFProduce/k)
- if Power==true then
- if Day == true and Rain == false then
- Weather = true
- if FirstPipeAverage < 177 or SecondPipeAverage < 177 then
- if FirstPipeAverage <= 177 and FirstProcent > 99 then
- FirstAverage = 999
- else
- FirstAverage = FirstPipeAverage
- end
- if SecondPipeAverage <= 177 and SecondProcent > 99 then
- SecondAverage = 999
- else
- SecondAverage = SecondPipeAverage
- end
- InjRate2 = math.floor(math.min(FirstAverage,SecondAverage))
- end
- else
- Weather = false
- end
- if FirstProcent < 50 or SecondProcent < 50 then
- TankLevel = false
- elseif FirstProcent >= 75 and SecondProcent >= 75 then
- TankLevel = true
- end
- if InjRate2 > InjRate1 and TankLevel == false then
- InjRate = InjRate1
- else
- InjRate = InjRate2
- end
- if TankLevel == true then
- InjRate = InjRate1
- end
- if FirstProcent < MinProcenttoBoost or SecondProcent < MinProcenttoBoost then
- InjRate = 2
- end
- if DraconicFluidGate == true then -- wenn Fluidgate vorhanden läuft reactor main mit dtfuel
- calcDTFuelInjRate()
- DTFuelInj.setFlowOverride(DTFuelInjRate)
- else -- sonst normal
- calcFuelInjRate()
- end
- elseif Power == false then
- if DraconicFluidGate == true then -- wenn Fluidgate vorhanden 0
- DTFuelInj.setFlowOverride(0)
- FuelInjRate = 0
- else -- sonst 0
- FuelInjRate = 0
- end
- end
- if FReactor.isIgnited() == false then
- FireUpcolor = colors.green
- ReactorStatus = "OFFLINE"
- RectorTextcolor = colors.red
- else
- FireUpcolor = colors.gray
- ReactorStatus = "ONLINE"
- RectorTextcolor = colors.green
- end
- RFOutput = FReactor.getProducing(RFOutput)/2500000
- InjRateText = FuelInjRate + DTFuelInjRate
- FReactor.setInjectionRate(FuelInjRate)
- RFOutputT = round((FReactor.getProducing()/2500000), 2)
- PlasmaHeat = round((FReactor.getPlasmaHeat()/1000000000), 2)
- CaseHeat = round((FReactor.getCaseHeat()/1000000000), 2)
- end
- -- Calcs DTFuelInjRate (max= 256 mb/t because its maximum of one rotary Conden )
- function calcDTFuelInjRate()
- if InjRate > 256 then
- calcFuelInjRate()
- DTFuelInjRate = 256
- else
- FuelInjRate = 0
- DTFuelInjRate = InjRate
- end
- end
- -- Calcs InjRate for Fusion-Reactor
- function calcFuelInjRate()
- if DraconicFluidGate == true then
- FuelInjRate = InjRate - 256
- else
- DTFuelInjRate = 0
- FuelInjRate = InjRate
- end
- if FuelInjRate%2 == 1 then -- Its possible to set InjRate Of Fusion-Reactor to 7, 9, 11, ... in Fusion-Reactor-GUI not possible!!! Maybe Bug??
- FuelInjRate = FuelInjRate + 1
- end
- if FuelInjRate > 98 then -- Its possible to set InjRate Of Fusion-Reactor over 98!!! Maybe Bug??? (For CheatMode set FuelInjRate = 354 for 1,56 GRF!!!)
- FuelInjRate = 98
- 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 DraconicFluxGate == true then
- ChargeLaser = FluxGate.setFlowOverride(Charge)
- end
- if MRFLaser >= 400 then
- if Auto == true then
- if DraconicFluidGate == true then -- wenn Fluidgate vorhanden 2
- DTFuelInj.setFlowOverride(2)
- FReactor.setInjectionRate(0)
- else -- sonst 2
- FReactor.setInjectionRate(2)
- end
- FireUp()
- elseif MRFLaser >= 400 and Auto == false then
- FluxGate.setFlowOverride(0)
- end
- end
- end
- -- Alarm + Hohlraum insert
- function FireUp()
- if FReactor.isIgnited() == false then
- Auto = false
- Power = true
- FireUpOK = true
- rs.setBundledOutput("back", colors.yellow, 1)
- FireUpcolor = colors.green
- calcInjRate()
- else
- FireUpcolor = colors.gray
- end
- end
- function ChargeOnOff()
- ChargeOn = true
- calcLaserAmplifier()
- end
- -- Liest die daten der pressure pipes aus
- function calcPipeStats()
- local FirstPipeInfo = FirstPipe.getAverages()
- local FirstPipeStats = FirstPipeInfo[1]
- if FirstPipeStats == nil then
- FirstPipeLiquid = "No Fluid"
- FirstPipeAverage = 0
- else
- FirstPipeLiquid = FirstPipeStats["name"]
- FirstPipeAverage = FirstPipeStats["average"]
- end
- local SecondPipeInfo = SecondPipe.getAverages()
- local SecondPipeStats = SecondPipeInfo[1]
- if SecondPipeStats == nil then
- SecondPipeLiquid = "No Fluid"
- SecondPipeAverage = 0
- else
- SecondPipeLiquid = SecondPipeStats["name"]
- SecondPipeAverage = SecondPipeStats["average"]
- end
- end
- -- Redstone Signale
- function RedstoneSignal()
- if rs.testBundledInput("back", colors.white) then
- Day = false
- else
- Day = true
- end
- if rs.testBundledInput("back", colors.lightBlue) then
- Rain = true
- else
- Rain = false
- end
- Day2 = tostring(Day)
- Rain2 = tostring(Rain)
- 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