Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = require("term")
- local computer = require("computer")
- local sides = require("sides")
- local component = require("component")
- local gpu = component.gpu
- --System requirements check
- if gpu.maxResolution() < 100 then
- io.stderr:write("Tier 3 GPU and Screen Required")
- computer.beep()
- os.sleep(0.2)
- computer.beep()
- os.exit(1)
- end
- if not component.isAvailable("reactor_logic_adapter") then
- io.stderr:write("No Reactor Connected.")
- computer.beep()
- os.sleep(0.2)
- computer.beep()
- os.sleep(0.2)
- computer.beep()
- os.exit(1)
- end
- if not component.isAvailable("redstone") then
- io.stderr:write("No RedstoneIO Connected.")
- computer.beep()
- os.sleep(0.2)
- computer.beep()
- os.sleep(0.2)
- computer.beep()
- os.sleep(0.2)
- computer.beep()
- os.exit(1)
- end
- local reactor = component.reactor_logic_adapter
- local screen = component.screen
- local rs = component.redstone
- local whiteColor = 0xFFFFFF
- local greenColor = 0x00B600
- local redColor = 0xFF0000
- local yellowColor = 0xFFDB00
- local blueColor = 0x006DFF
- gpu.setResolution(46, 19)
- -- User settings --
- local insertLevel = 600 -- set min level for inserting fuel // Default: 600
- local critLevel = 400 -- below this level computer start beeping // Default: 400
- local rate = 4 -- set to desired value of ignition level // Default: 4
- local RSTri = sides.north -- rs signal for start prodution (insert) of tritium // Default: sides.north
- local RSDeu = sides.south -- rs signal for start prodution (insert) of deuterium // Default: sides.south
- local RSAL = sides.top -- rs signal for external alarm // Default: sides.top
- local language = "EN" -- EN = english, DE = Deutsch, CZ = Cesky // Default: EN
- -- End if User settings --
- --- Language loading --
- if language == "EN" then
- gasDeu = "Deuterium:"
- gasTri = "Tritium:"
- TempR = "Reactor Temperature:"
- TempP = "Plasma Temperature:"
- cRate = "Current rate:"
- rStatus = "Status"
- iDeu = "Deuterium injection:"
- iTri = "Tritium injection:"
- iY = "True"
- iN = "False"
- bStatus = "Energy buffer:"
- warningTri1 = " Warning low Tritium, inserting fuel "
- warningDeu1 = " Warning low Deuterium, inserting fuel "
- ok = " Reactor is Stable "
- rOFF = " Reactor is OFF "
- elseif language == "DE" then
- gasDeu = "Deuterium:"
- gasTri = "Tritium:"
- TempR = "Reaktortemperatur:"
- TempP = "Plasmatemperatur:"
- cRate = "Derzeitige Rate:"
- rStatus = "Statusbericht"
- iDeu = "Deuteriuminjektion:"
- iTri = "Tritiuminjektion:"
- iY = "An"
- iN = "Aus"
- bStatus = "Energiespeicher:"
- warningTri1 = " Warnung wenig Tritium - einfüllen"
- warningDeu1 = " Warnung wenig Deuterium - einfüllen"
- ok = " Reaktor ist stabil "
- rOFF = " Außer Betrieb "
- elseif language == "CZ" then
- gasDeu = "Deuterium:"
- gasTri = "Tritium:"
- TempR = "Teploměr - Reaktor:"
- TempP = "Teploměr - Plasma:"
- cRate = "Vstřikování:"
- rStatus = "Status"
- iDeu = "Doplnění - Deuteria:"
- iTri = "Doplnění - Tritia:"
- iY = "Ano"
- iN = "Ne"
- bStatus = "Zásoba energie:"
- warningTri1 = " Varování málo Tritia, doplňuji "
- warningDeu1 = " Varování málo Deuteria, doplňuji "
- ok = " V pořádku "
- rOFF = " Mimo provoz "
- else
- io.stderr:write("Wrong name of language packet or your language is not supported!")
- computer.beep()
- computer.beep()
- os.exit(1)
- end
- -- end of Langoage loading
- -- Functions --
- local function colorTextGYR(rule1, rule2, rule3, posX, posY, text)
- if (rule1) then gpu.setForeground(greenColor) elseif(rule2) then gpu.setForeground(yellowColor) elseif (rule3) then gpu.setForeground(redColor) end
- term.setCursor(posX, posY)
- print(text .." ")
- gpu.setForeground(whiteColor)
- end
- local function colorTextGR(rule, PosX, PosY, textT, textF)
- if (rule) then
- gpu.setForeground(greenColor)
- textR = textT
- else
- gpu.setForeground(redColor)
- textR = textF
- end
- term.setCursor(PosX, PosY)
- print(textR .." ")
- gpu.setForeground(whiteColor)
- end
- local function round(num1, numDecimalPlaces)
- if numDecimalPlaces and numDecimalPlaces>0 then
- local mult = 10^numDecimalPlaces
- return math.floor(num1 * mult + 0.5) / mult
- end
- return math.floor(num1 + 0.5)
- end
- local function convert(source, posX1, posY1, devi, multi, unit)
- var1 = source / devi
- if multi == 0 then multi = 1 end
- var1 = var1 * multi
- term.setCursor(posX1, posY1)
- print(round(var1, 2) ..unit)
- end
- local function Status(tx1, ty1, mes0, mes1, mes2, mes3)
- if (reactor.isIgnited() == false) then
- term.setCursor(3, 11)
- print(mes0)
- else
- if(reactor.getDeuterium() > insertLevel and reactor.getTritium() > insertLevel) then
- reactor.setInjectionRate(rate)
- term.setCursor(tx1, ty1)
- gpu.setForeground(greenColor)
- print(mes1)
- gpu.setForeground(whiteColor)
- rs.setOutput(RSAL, 0)
- end
- if(reactor.getDeuterium() < insertLevel) then
- reactor.setInjectionRate(2)
- rs.setOutput(RSDeu, 15)
- term.setCursor(tx1, ty1)
- gpu.setForeground(yellowColor)
- print(mes2)
- gpu.setForeground(whiteColor)
- rs.setOutput(RSAL, 15)
- end
- if(reactor.getTritium() < insertLevel) then
- reactor.setInjectionRate(2)
- rs.setOutput(RSTri, 15)
- term.setCursor(tx1, ty1)
- gpu.setForeground(yellowColor)
- print(mes3)
- gpu.setForeground(whiteColor)
- rs.setOutput(RSAL, 15)
- end
- end
- end
- local function RSoff()
- if(reactor.getDeuterium() > 999) then
- rs.setOutput(RSDeu, 0)
- end
- if(reactor.getTritium() > 999) then
- rs.setOutput(RSTri, 0)
- end
- end
- local function infoScreen()
- term.setCursor(34, 19)
- print("®Fredyman_95")
- gpu.setForeground(whiteColor)
- term.setCursor(2, 2)
- print(gasDeu)
- term.setCursor(2, 3)
- print(gasTri)
- term.setCursor(2,4)
- print(TempR)
- term.setCursor(2,5)
- print(TempP)
- term.setCursor(2,6)
- print(cRate)
- if language == "DE" then term.setCursor(18,9) else
- term.setCursor(21,9) end
- print(rStatus)
- term.setCursor(2,10)
- print("┌──────────────────────────────────────────┐")
- term.setCursor(2, 11)
- print("│")
- term.setCursor(45, 11)
- print("│")
- term.setCursor(2, 12)
- print("└──────────────────────────────────────────┘")
- term.setCursor(2,14)
- print(iDeu)
- term.setCursor(2,15)
- print(iTri)
- term.setCursor(2,17)
- print(bStatus)
- end
- local function fillInfo()
- colorTextGYR(reactor.getDeuterium() > 800, reactor.getDeuterium() > insertLevel, reactor.getDeuterium() < critLevel, 13, 2, reactor.getDeuterium())
- colorTextGYR(reactor.getTritium() > 800, reactor.getTritium() > insertLevel, reactor.getTritium() < critLevel, 11, 3, reactor.getTritium())
- convert(reactor.getCaseHeat(), 23, 4, 1000000, 1, " °MC ")
- convert(reactor.getPlasmaHeat(), 22, 5, 1000000, 1, " °MC ")
- term.setCursor(16,6)
- if language == "DE" then term.setCursor(19,6) end
- print(reactor.getInjectionRate())
- Status(3, 11, rOFF, ok, warningDeu1, warningTri1)
- RSoff()
- colorTextGR(rs.getOutput(RSDeu) == 15, 23, 14, iY, iN)
- colorTextGR(rs.getOutput(RSTri) == 15, 21, 15, iY, iN)
- if language == "DE" then convert(reactor.getEnergy(), 19, 17, 10000000, 4, " / 400 MRF ") else
- convert(reactor.getEnergy(), 18, 17, 10000000, 4, " / 400 MRF ")end
- end
- term.clear()
- infoScreen()
- while true do
- fillInfo()
- os.sleep()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement