Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- /---------------------------------\
- | The Big Reactors Status Display |
- \---------------------------------
- ]]
- -- =============
- -- Configuration
- -- =============
- -- This is the side on which your reactor is connected
- local turbine0_side = "BigReactors-Turbine_0"
- local turbine1_side = "BigReactors-Turbine_1"
- -- This is the side on which your monitor is connected
- local monitor_side = "right"
- -- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- -- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- -- If the reactor is not connected, exit the program
- if not peripheral.isPresent(turbine0_side) then
- print("Please check, that the turbine is connected to the same side as in your config!")
- return
- end
- if not peripheral.isPresent(turbine1_side) then
- print("Please check, that the turbine is connected to the same side as in your config!")
- return
- end
- -- If the monitor is not connected, exit
- if not peripheral.isPresent(monitor_side) then
- print("Please check, that the monitor is connected to the same side as in your config!")
- return
- end
- -- Wrap the peripherals
- local t1 = peripheral.wrap(turbine0_side)
- local t2 = peripheral.wrap(turbine1_side)
- while not t1.getConnected() do sleep(10) end
- while not t2.getConnected() do sleep(10) end
- local m = peripheral.wrap(monitor_side)
- print("The program is now running on the monitor!")
- -- BEGIN FUNCTIONS PART
- function clear()
- m.clear()
- m.setTextColor(colors.white)
- m.setBackgroundColor(colors.black)
- m.setCursorPos(1, 1)
- end
- function resetColors()
- m.setTextColor(colors.white)
- m.setBackgroundColor(colors.black)
- end
- function newLine()
- local x, y = m.getCursorPos()
- m.setCursorPos(1, y+1)
- end
- function drawUI()
- m.write("/---------------------------\\")
- for x = 2, 19, 1 do
- m.setCursorPos(1, x)
- m.write("|")
- m.setCursorPos(29, x)
- m.write("|")
- end
- m.setCursorPos(2, 8)
- m.write("---------------------------")
- m.setCursorPos(1, 19)
- m.write("\\---------------------------/")
- end
- -- END FUNCTIONS PART
- -- Repeat forever
- while true do
- -- Clear the terminal
- clear()
- -- Draw the basic UI layout
- resetColors()
- drawUI()
- -- Turbine Status
- local t1active = t1.getActive()
- local t2active = t2.getActive()
- m.setCursorPos(3, 2)
- m.write("Turbine 1: ")
- m.setCursorPos(3, 9)
- m.write("Turbine 2: ")
- m.setCursorPos(17, 2)
- if t1active then
- m.setBackgroundColor(colors.green)
- m.setTextColor(colors.white)
- m.write(" ACTIVE ")
- else
- m.setBackgroundColor(colors.red)
- m.setTextColor(colors.white)
- m.write(" INACTIVE ")
- end
- m.setCursorPos(17, 9)
- if t2active then
- m.setBackgroundColor(colors.green)
- m.setTextColor(colors.white)
- m.write(" ACTIVE ")
- else
- m.setBackgroundColor(colors.red)
- m.setTextColor(colors.white)
- m.write(" INACTIVE ")
- end
- -- END Turbine Status
- -- Turbine RPM
- local rpmt1
- local rpmt2
- resetColors()
- rpmt1 = math.ceil(t1.getRotorSpeed())
- m.setCursorPos(3, 4)
- m.setTextColor(colors.white)
- m.write("Rotor Speed: ")
- m.setCursorPos(18, 4)
- m.setTextColor(colors.yellow)
- m.write(rpmt1 .. " RPM")
- rpmt2 = math.ceil(t2.getRotorSpeed())
- m.setCursorPos(3, 11)
- m.setTextColor(colors.white)
- m.write("Rotor Speed: ")
- m.setCursorPos(18, 11)
- m.setTextColor(colors.yellow)
- m.write(rpmt2 .. " RPM")
- -- END Turbine RPM
- -- Turbine Flow Rate
- resetColors()
- local flowt1
- local flowt2
- flowt1 = math.floor(t1.getFluidFlowRate())
- m.setCursorPos(3, 5)
- m.setTextColor(colors.white)
- m.write("Flow Rate:")
- m.setCursorPos(18, 5)
- m.setTextColor(colors.cyan)
- m.write(flowt1 .. " mB/T")
- flowt2 = math.floor(t2.getFluidFlowRate())
- m.setCursorPos(3, 12)
- m.setTextColor(colors.white)
- m.write("Flow Rate:")
- m.setCursorPos(18, 12)
- m.setTextColor(colors.cyan)
- m.write(flowt2 .. " mB/T")
- -- END Flow Rate
- -- Turbine Energy Output
- resetColors()
- local powert1
- local powert2
- powert1 = math.floor(t1.getEnergyProducedLastTick())
- m.setCursorPos(3, 6)
- m.setTextColor(colors.white)
- m.write("Energy Output:")
- m.setCursorPos(18, 6)
- m.setTextColor(colors.purple)
- m.write(powert1 .. " RF/T")
- powert2 = math.floor(t2.getEnergyProducedLastTick())
- m.setCursorPos(3, 13)
- m.setTextColor(colors.white)
- m.write("Energy Output:")
- m.setCursorPos(18, 13)
- m.setTextColor(colors.purple)
- m.write(powert2 .. " RF/T")
- -- END Energy Output
- -- Total Energy
- resetColors()
- m.setCursorPos(8, 16)
- m.setTextColor(colors.white)
- m.write("Total Output:")
- resetColors()
- m.setCursorPos(10, 17)
- m.setTextColor(colors.purple)
- m.write(powert1 + powert2.. " RF/T")
- -- END Total Energy
- -- Sleep for a 1/4 of a second (decreases CPU load significantly)...
- sleep(1)
- end
Add Comment
Please, Sign In to add comment