Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Hardware Variables------------------------
- local m1 = peripheral.wrap("monitor_25")
- local m2 = peripheral.wrap("monitor_3")
- local m3 = peripheral.wrap("monitor_23")
- local m4 = peripheral.wrap("monitor_22")
- local r1 = peripheral.wrap("BigReactors-Reactor_2")
- local t1 = peripheral.wrap("BigReactors-Turbine_1")
- local t2 = peripheral.wrap("BigReactors-Turbine_0")
- --Control Button Toggle -------------------
- function btn(y,state)
- if state == "on" then
- m1.setCursorPos(18,y)
- m1.setBackgroundColor(colors.green)
- m1.write(" ON ")
- m1.setCursorPos(25,y)
- m1.setBackgroundColor(colors.gray)
- m1.write(" OFF ")
- elseif state == "off" then
- m1.setCursorPos(18,y)
- m1.setBackgroundColor(colors.gray)
- m1.write(" ON ")
- m1.setCursorPos(25,y)
- m1.setBackgroundColor(colors.red)
- m1.write(" OFF ")
- end
- end
- --Start Program-----------------------------
- --Control panel initialize
- m1.clear()
- --Reactor
- m1.setCursorPos(1,1)
- m1.setBackgroundColor(colors.black)
- m1.write("Reactor")
- btn(1,"on")
- r1.setActive(true)
- --Turbine 1
- m1.setCursorPos(1,2)
- m1.setBackgroundColor(colors.black)
- m1.write("Turbine 1")
- btn(2,"on")
- t1.setActive(true)
- --Turbine 2
- m1.setCursorPos(1,3)
- m1.setBackgroundColor(colors.black)
- m1.write("Turbine 2")
- btn(3,"on")
- t2.setActive(true)
- --Blast door
- m1.setCursorPos(1,5)
- m1.setBackgroundColor(colors.black)
- m1.write("Blast Door")
- btn(5,"off")
- redstone.setOutput("top",false)
- --Program Loop-------------------------------
- while true do
- --Reactor display-----------
- m2.clear()
- m2.setTextColor(colors.white)
- m2.setCursorPos(1,1)
- m2.write("Reactor")
- --Status
- m2.setCursorPos(15,1)
- m2.write("Status:")
- m2.setCursorPos(23,1)
- if r1.getActive() == true then
- m2.setTextColor(colors.green)
- m2.write("ONLINE")
- btn(1,"on")
- else
- m2.setTextColor(colors.red)
- m2.write("OFFLINE")
- btn(1,"off")
- end
- m2.setTextColor(colors.white)
- --Temp control
- local temp = math.floor(r1.getFuelTemperature())
- local rods = r1.getControlRodLevel(0)
- m2.setCursorPos(1,4)
- m2.write("Temp:")
- if temp >= 2000 then
- m2.setCursorPos(19,4)
- m2.setTextColor(colors.red)
- r1.setAllContolRodLevels(rods + 5)
- elseif temp >= 1500 then
- m2.setCursorPos(19,4)
- m2.setTextColor(colors.orange)
- r1.setAllContolRodLevels(rods + 1)
- elseif temp >= 1000 then
- m2.setCursorPos(19,4)
- m2.setTextColor(colors.yellow)
- r1.setAllContolRodLevels(rods + 1)
- elseif (temp < 1000) and (temp > 500) then
- m2.setCursorPos(20,4)
- m2.setTextColor(colors.green)
- elseif temp <= 500 then
- m2.setCursorPos(20,4)
- m2.setTextColor(colors.white)
- r1.setAllControlRodLevels(rods - 1)
- end
- m2.write(temp)
- m2.setTextColor(colors.white)
- m2.setCursorPos(25,4)
- m2.write(" C")
- --Rods
- m2.setCursorPos(1,6)
- m2.write("Reactor Output:")
- m2.setCursorPos(23,6)
- m2.write(100 - rods)
- m2.setCursorPos(25,6)
- m2.write(" %")
- --Steam Gen
- m2.setCursorPos(1,8)
- m2.write("Steam Gen:")
- m2.setCursorPos(19,8)
- m2.write(math.floor(r1.getHotFluidProducedLastTick()))
- m2.setCursorPos(25,8)
- m2.write(" mb/t")
- --Fuel Rate
- m2.setCursorPos(1,10)
- m2.write("Fuel Rate:")
- m2.setCursorPos(19,10)
- m2.write(r1.getFuelConsumedLastTick())
- m2.setCursorPos(25,10)
- m2.write(" mb/t")
- --Turbine 1 display-----------
- m3.clear()
- m3.setTextColor(colors.white)
- m3.setCursorPos(1,1)
- m3.write("Turbine 1")
- m3.setCursorPos(15,1)
- m3.write("Status:")
- m3.setCursorPos(16,3)
- m3.write("Coils:")
- m3.setCursorPos(1,5)
- m3.write("Power:")
- m3.setCursorPos(1,7)
- m3.write("Rate:")
- m3.setCursorPos(1,9)
- m3.write("RPM:")
- m3.setCursorPos(1,11)
- m3.write("Steam Flow:")
- --Turbine 2 display-----------
- m4.clear()
- m4.setTextColor(colors.white)
- m4.setCursorPos(1,1)
- m4.write("Turbine 2")
- m4.setCursorPos(15,1)
- m4.write("Status:")
- m4.setCursorPos(16,3)
- m4.write("Coils:")
- m4.setCursorPos(1,5)
- m4.write("Power:")
- m4.setCursorPos(1,7)
- m4.write("Rate:")
- m4.setCursorPos(1,9)
- m4.write("RPM:")
- m4.setCursorPos(1,11)
- m4.write("Steam Flow:")
- --Button Press--------------------------------
- os.startTimer(0.5)
- while true do
- local evt = {os.pullEvent()}
- if evt[1]=="timer" then
- break
- elseif evt[1]=="monitor_touch" then
- local x,y = evt[3],evt[4]
- if evt[2] == "monitor_25" then
- --ON--
- if x>=18 and x<=22 then
- btn(y,"on")
- if y==1 then
- r1.setActive(true)
- elseif y==2 then
- t1.setActive(true)
- elseif y==3 then
- t2.setActive(true)
- elseif y==4 then
- --blank line
- elseif y==5 then
- redstone.setOutput("top",true)
- end
- --OFF--
- elseif x>25 and x<=30 then
- btn(y,"off")
- if y==1 then
- r1.setActive(false)
- elseif y==2 then
- t1.setActive(false)
- elseif y==3 then
- t2.setActive(false)
- elseif y==4 then
- --blank line
- elseif y==5 then
- redstone.setOutput("top",false)
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement