Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This is the variables for the reactor function
- ]]
- mon = peripheral.wrap("top")
- --if mon ~= nil then
- local term = mon
- --end
- max = 10000000
- reactor1 = peripheral.wrap("BigReactors-Reactor_3")
- reactor2 = peripheral.wrap("")
- reactor3 = peripheral.wrap("")
- reactor4 = peripheral.wrap("")
- --[[
- Variables for the main program, please do not touch
- ]]
- allToggle = true
- option = true
- x,y = term.getSize()
- running = true
- index = 1
- default = {
- background = "black",
- textC = "white"
- }
- button = {
- button1 = {text = "Back",bx = 1, by = y},
- button2 = {text = "Overview", bx = math.floor((x/2)-(string.len("Overview")/2)), by = y},
- button3 = {text = "Next",bx = x-string.len("Next")+1, by = y},
- button4 = {text = "Single",bx = math.floor((x/2)-(string.len("Single")/2)), by = y}
- }
- buttonSize = table.getn(button)
- local function drawButton(state1,state2,state3,state4,colour)
- if colour == nil then colour = "red" end
- term.setBackgroundColour(colours[colour])
- if state1 then
- term.setCursorPos(button.button1.bx,button.button1.by)
- term.write(button.button1.text)
- end
- if state2 then
- term.setCursorPos(button.button2.bx,button.button2.by)
- term.write(button.button2.text)
- end
- if state3 then
- term.setCursorPos(button.button3.bx,button.button3.by)
- term.write(button.button3.text)
- end
- if state4 then
- term.setCursorPos(button.button4.bx,button.button4.by)
- term.write(button.button4.text)
- end
- term.setBackgroundColour(colours[default.background])
- end
- local function flashButton(b)
- if b == 1 then drawButton(true,false,false,false,"green") end
- if b == 2 then drawButton(false,true,false,false,"green") end
- if b == 3 then drawButton(false,false,true,false,"green") end
- if b == 4 then drawButton(false,false,false,true,"green") end
- sleep(0.25)
- drawButton(true,true,true)
- end
- local function clearScreen()
- for i = 1,y-1 do
- term.setCursorPos(1,i)
- term.clearLine()
- end
- end
- term.clear()
- local function printBar(x,y,val,per)
- term.setCursorPos(x,y)
- term.setBackgroundColour(colours[default.background])
- term.clearLine()
- term.setBackgroundColour(colours.red)
- for i = 1,25 do
- term.write(" ")
- end
- term.setCursorPos(x,y)
- term.setBackgroundColour(colours.green)
- for i = 1,val do
- term.write(" ")
- end
- term.setBackgroundColour(colours[default.background])
- term.setCursorPos(x+26,y)
- term.write(per.."%")
- end
- act2 = false
- act3 = false
- act4 = false
- function printReactor()
- while running do
- act1 = reactor1.getActive()
- cur1 = reactor1.getEnergyStored()
- pert1 = math.floor((cur1/max)*100)
- per1 = math.floor(pert1/4)
- cur2 = 0
- pert2 = math.floor((cur2/max)*100)
- per2 = math.floor(pert2/4)
- cur3 = 0
- pert3 = math.floor((cur3/max)*100)
- per3 = math.floor(pert3/4)
- cur4 = 0
- pert4 = math.floor((cur4/max)*100)
- per4 = math.floor(pert4/4)
- rft1 = reactor1.getEnergyProducedLastTick()
- rft2 = 0
- rft3 = 0
- rft4 = 0
- if option then
- clearScreen()
- term.setTextColour(colours.yellow)
- term.setCursorPos(1,1)
- term.write("OVERVIEW MODE")
- term.setTextColour(colours[default.textC])
- term.setCursorPos(1,3)
- term.setTextColour(colours.orange)
- term.write("Reactor 1: ")
- term.setTextColour(colours[default.textC])
- term.write(rft1.." RF/t")
- if act1 then
- term.setTextColour(colours.green)
- term.setCursorPos(1,4)
- term.write("Online")
- else
- term.setTextColour(colours.red)
- term.setCursorPos(1,4)
- term.write("Offline")
- end
- term.setTextColour(colours[default.textC])
- printBar(1,5,per1,pert1)
- term.setCursorPos(1,6)
- term.setTextColour(colours.orange)
- term.write("Reactor 2: ")
- term.setTextColour(colours[default.textC])
- term.write(rft2.." RF/t")
- if act2 then
- term.setTextColour(colours.green)
- term.setCursorPos(1,7)
- term.write("Online")
- else
- term.setTextColour(colours.red)
- term.setCursorPos(1,7)
- term.write("Offline")
- end
- term.setTextColour(colours[default.textC])
- printBar(1,8,per2,pert2)
- term.setCursorPos(1,9)
- term.setTextColour(colours.orange)
- term.write("Reactor 3: ")
- term.setTextColour(colours[default.textC])
- term.write(rft3.." RF/t")
- if act3 then
- term.setTextColour(colours.green)
- term.setCursorPos(1,10)
- term.write("Online")
- else
- term.setTextColour(colours.red)
- term.setCursorPos(1,10)
- term.write("Offline")
- end
- term.setTextColour(colours[default.textC])
- printBar(1,11,per3,pert3)
- term.setCursorPos(1,12)
- term.setTextColour(colours.orange)
- term.write("Reactor 4: ")
- term.setTextColour(colours[default.textC])
- term.write(rft4.." RF/t")
- if act4 then
- term.setTextColour(colours.green)
- term.setCursorPos(1,13)
- term.write("Online")
- else
- term.setTextColour(colours.red)
- term.setCursorPos(1,13)
- term.write("Offline")
- end
- term.setTextColour(colours[default.textC])
- printBar(1,14,per4,pert4)
- term.setCursorPos(1,16)
- if allToggle then
- term.setBackgroundColour(colours.red)
- else
- term.setBackgroundColour(colours.green)
- end
- term.write("Toggle All")
- term.setBackgroundColour(colours[default.background])
- else
- --SINGLE MODE
- clearScreen()
- term.setCursorPos(1,1)
- term.setBackgroundColour(colours[default.background])
- term.setTextColour(colours.yellow)
- term.write("Reactor: "..index)
- term.setBackgroundColour(colours[colour])
- term.setTextColour(colours[default.textC])
- term.setBackgroundColour(colours[default.background])
- if index == 1 then
- --cur1 = reactor1.getEnergyStored()
- term.setCursorPos(1,3)
- term.write("RF Stored: "..cur1.."/"..max)
- printBar(1,4,per1,pert1)
- term.setCursorPos(1,6)
- term.write("Core Temperature: ")
- term.setCursorPos(1,8)
- term.write("Waste Produced (MB/t): ")
- term.setCursorPos(1,10)
- term.write("Fuel Rod Insertion: ")
- elseif index == 2 then
- term.setCursorPos(1,3)
- term.write("RF Stored: "..cur2.."/"..max)
- printBar(1,3,per2,pert2)
- elseif index == 3 then
- term.setCursorPos(1,3)
- term.write("RF Stored: "..cur3.."/"..max)
- printBar(1,3,per3,pert3)
- elseif index == 4 then
- term.setCursorPos(1,3)
- term.write("RF Stored: "..cur4.."/"..max)
- printBar(1,3,per4,pert4)
- end
- end
- sleep(1)
- end
- end
- function gui()
- while running do
- if option then
- drawButton(false,false,false,true)
- else
- if index == 1 then
- drawButton(false,true,true,false)
- elseif index == 4 then
- drawButton(true,true,false,false)
- else
- drawButton(true,true,true,false)
- end
- end
- event, param1, param2, param3 = os.pullEvent()
- if event == "mouse_click" then
- if param2 >= button.button1.bx and param2 <= (button.button1.bx + #button.button1.text) and param3 == button.button1.by and index ~= 1 and option == false then
- flashButton(1)
- index = index - 1
- clearScreen()
- elseif param2 >= button.button2.bx and param2 <= (button.button2.bx + #button.button2.text) and param3 == button.button2.by and option == false then
- flashButton(2)
- option = true
- elseif param2 >= button.button3.bx and param2 <= (button.button3.bx + #button.button3.text) and param3 == button.button3.by and index ~= 4 and option == false then
- flashButton(3)
- index = index + 1
- clearScreen()
- elseif param2 >= button.button4.bx and param2 <= (button.button4.bx + #button.button4.text) and param3 == button.button4.by and option == true then
- flashButton(4)
- option = false
- elseif param2 >= 1 and param2 <= 1+string.len("Toggle All") and param3 == 16 then
- if allToggle then
- allToggle = false
- act1 = true
- act2 = true
- act3 = true
- act4 = true
- else
- allToggle = true
- act1 = false
- act2 = false
- act3 = false
- act4 = false
- end
- end
- elseif event == "key" then
- if param1 == keys.y then
- running = false
- term.setBackgroundColour(colours[default.background])
- term.clear()
- term.setCursorPos(1,1)
- end
- end
- term.setCursorPos(1,y)
- term.clearLine()
- end
- end
- parallel.waitForAny(gui,printReactor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement