Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Program made by jamawie
- -------------------------
- reactor = peripheral.wrap("BigReactors-Reactor_12")
- turbine = peripheral.wrap("BigReactors-Turbine_9")
- mon = peripheral.wrap("back")
- speaker = peripheral.wrap("right")
- reactivity = 10 --standard: 50
- speakDelay = 60 -- 1==0.5 Seconds
- -------------------------
- local maxTemp = 2500
- local maxEnergy = 1000000
- local maxHotFluidReactor = math.floor(reactor.getHotFluidAmountMax()/100)*50
- local maxEnergyTurbine = math.floor(maxEnergy/100)*80
- local x,y = mon.getSize()
- local turbineOn = true
- local systemOnlineOffline = "offline"
- local reactorOnlineOffline= false
- local processEnergy = math.floor(maxEnergy/x-2)
- local processFuel = math.floor(reactor.getFuelAmountMax()/x-2)
- local delay = 0
- -------------------------
- function actualising()
- turbineEnergyStored = turbine.getEnergyStored()
- turbineRotorSpeed = turbine.getRotorSpeed()
- turbineFluidFlowRate = turbine.getFluidFlowRateMaxMax()
- turbinePowerOutput = turbine.getEnergyProducedLastTick()
- turbinePowerPercent = math.floor(turbine.getEnergyStored()/maxEnergy)*100
- turbinePowerProcess = math.floor(turbine.getEnergyStored()/processEnergy)
- reactorCasingTemperature = reactor.getCasingTemperature()
- reactorHotFluid = reactor.getHotFluidAmount()
- reactorFluidPercent = math.floor(reactor.getFuelAmount()/reactor.getFuelAmountMax())*100
- reactorFluidProcess = math.floor(reactor.getFuelAmount()/processFuel)
- turbineInductionCoilsOnOff = turbine.getInductorEngaged()
- end
- function reactorF()
- if not reactor.getActive() then
- reactor.setActive(true)
- end
- if reactorHotFluid<=5000 and reactorCasingTemperature<=400 then
- reactor.setAllControlRodLevels(reactivity)
- reactorOnlineOffline = true
- else
- reactor.setAllControlRodLevels(100)
- reactorOnlineOffline = false
- end
- end
- function turbineF()
- if turbineEnergyStored <=100000 then
- turbineOn=true
- elseif turbineEnergyStored >= maxEnergyTurbine then
- turbineOn=false
- end
- if turbineEnergyStored<=maxEnergyTurbine and turbineOn then
- systemOnlineOffline = "online"
- if not turbine.getActive() then
- turbine.setActive(true)
- end
- if turbineRotorSpeed>1810 then
- turbine.setInductorEngaged(true)
- if turbineRotorSpeed<1820 then
- turbine.setFluidFlowRateMax(800)
- end
- if turbineRotorSpeed>1900 then
- turbine.setFluidFlowRateMax(0)
- end
- elseif turbineRotorSpeed<1810 then
- turbine.setFluidFlowRateMax(850)
- if turbineRotorSpeed>1700 then
- turbine.setFluidFlowRateMax(850)
- end
- if turbineRotorSpeed<1700 then
- turbine.setFluidFlowRateMax(turbine.getFluidFlowRateMaxMax())
- turbine.setInductorEngaged(false)
- end
- end
- else
- turbine.setFluidFlowRateMax(0)
- turbine.setInductorEngaged(false)
- systemOnlineOffline = "offline"
- end
- end
- function draw()
- name = "Reactor-/Turbinesteuerung"
- -------------------------
- mon.setBackgroundColor(colors.black)
- for i=1,y do
- mon.setCursorPos(1,i)
- for j=1,x do
- mon.write(" ")
- end
- end
- mon.setBackgroundColor(colors.cyan)
- mon.setCursorPos(1,1)
- for i=1,x do
- mon.write(" ")
- end
- mon.setTextColor(colors.black)
- mon.setCursorPos(math.floor((x-#name)/2)+1,1)
- mon.write(name)
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,2)
- mon.write("System Status:")
- mon.setCursorPos(1,4)
- mon.write("Reactor:")
- mon.setCursorPos(1,5)
- mon.write("Induction Coils:")
- mon.setCursorPos(1,6)
- mon.write("Power Output:")
- mon.setCursorPos(1,7)
- mon.write("Speed:")
- mon.setCursorPos(1,9)
- mon.write("Power:")
- mon.setCursorPos(1,11)
- mon.write("Fuel:")
- mon.setCursorPos(x-#systemOnlineOffline,2)
- if systemOnlineOffline=="online" then mon.setTextColor(colors.lime) else mon.setTextColor(colors.red) end
- mon.write(systemOnlineOffline)
- if reactorOnlineOffline then mon.setCursorPos(x-2,4); mon.setTextColor(colors.lime); mon.write("on") else mon.setCursorPos(x-3,4); mon.setTextColor(colors.red); mon.write("off") end
- if turbineInductionCoilsOnOff then mon.setCursorPos(x-2,5); mon.setTextColor(colors.lime); mon.write("on") else mon.setCursorPos(x-3,5); mon.setTextColor(colors.red); mon.write("off") end
- mon.setCursorPos(x-3-5,6); mon.setTextColor(colors.white)
- mon.write(turbinePowerOutput)
- mon.setCursorPos(x-3,6)
- mon.write("RF/T ")
- mon.setCursorPos(x-4-4,7)
- mon.write(turbineRotorSpeed)
- mon.setCursorPos(x-4,7)
- mon.write(" RPM ")
- mon.setBackgroundColor(colors.gray)
- for i=10,12,2 do
- mon.setCursorPos(2,i)
- for j=1,x-2 do
- mon.write(" ")
- end
- end
- mon.setCursorPos(2,10)
- mon.setBackgroundColor(colors.orange)
- for i=1,turbinePowerProcess do
- mon.write(" ")
- end
- mon.setCursorPos(2,12)
- mon.setBackgroundColor(colors.yellow)
- for i=1,reactorFluidProcess do
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(x,12)
- mon.write(" ")
- end
- function start_screen()
- mon.clear()
- x,y = mon.getSize()
- len1 = 24
- midx = math.floor((x-len1)/2)
- midy = math.floor(y/2)
- mon.setCursorPos(midx,midy)
- mon.setTextColor(colors.lightGray)
- mon.write("Reactor-/Turbinesteuerung")
- len1 = 14
- midx = math.floor((x-len1)/2)
- midy = midy+1
- mon.setCursorPos(midx,midy)
- mon.setTextColor(colors.lightGray)
- mon.write("(C) by jamawie")
- len1 = 18
- midx = math.floor((x-len1)/2)
- midy = midy+2
- mon.setCursorPos(midx,midy)
- mon.setTextColor(colors.lightGray)
- mon.write("")
- mon.setCursorPos(2,y)
- mon.setTextColor(colors.red)
- mon.write("Weitergabe nicht gestattet!")
- mon.setTextColor(colors.black)
- sleep(10)
- end
- function offlineScreen(offArg)
- mon.clear()
- x,y = mon.getSize()
- len1 = 7
- midx = math.floor((x-len1)/2)
- midy = math.floor(y/2)
- mon.setCursorPos(midx,midy)
- mon.setTextColor(colors.lightGray)
- mon.write("offline")
- offStringPlayerOffline = "Spieler nicht online!"
- offStringNoFuel = "Kein Fuel vorhanden!"
- len2 = string.len(offStringPlayerOffline)
- midx2 = math.floor((x-len2)/2)
- len3 = string.len(offStringNoFuel)
- midx3 = math.floor((x-len3)/2)
- if offArg=="offline" then
- mon.setCursorPos(midx2,y)
- mon.setTextColor(colors.lightGray)
- mon.write(offStringPlayerOffline)
- elseif offArg=="noFuel" then
- mon.setCursorPos(midx3,y)
- mon.setTextColor(colors.lightGray)
- mon.write(offStringNoFuel)
- end
- mon.setTextColor(colors.black)
- end
- function redIn()
- sides = {"top","bottom","left","right","front","back"}
- for i=1,#sides do
- resault = rs.getInput(sides[i])
- if resault==true then
- return true
- end
- end
- return false
- end
- function eventHandler()
- while true do
- event, arg1, arg2, arg3 = os.pullEvent()
- if event == "char" and not inManualMode then
- local ch = string.lower(arg1)
- if ch == "q" then
- elseif ch == "r" then
- os.reboot()
- elseif ch == "u" then
- if fs.exists("update") then
- shell.run("update")
- else
- shell.run("pastebin get VfHgjUsS update")
- shell.run("update")
- end
- end
- end
- end
- end
- function speak()
- end
- -----------------------------
- function main()
- term.setCursorPos(1,1)
- term.write("Display redirected to Monitor. Type r to reboot, or")
- term.setCursorPos(1,2)
- term.write("q to quit and return control to this terminal.")
- term.setCursorPos(1,3)
- term.write("Press u to update!")
- start_screen()
- while true do
- if redIn() then
- mon.clear()
- actualising()
- draw()
- reactorF()
- turbineF()
- speak()
- else
- offlineScreen("offline")
- reactor.setActive(false)
- turbine.setFluidFlowRateMax(0)
- turbine.setInductorEngaged(false)
- if turbine.getRotorSpeed()<=1 then
- turbine.setActive(false)
- end
- sleep(0.5)
- end
- sleep(0.15)
- delay=delay+1
- end
- end
- parallel.waitForAny(main, eventHandler)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement