Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This is the variables for the reactor function
- ]]
- mon = peripheral.find("monitor")
- if mon ~= nil then
- local term = mon
- end
- reactor1 = peripheral.wrap("BigReactors-Reactor_2")
- reactor2 = peripheral.wrap("")
- reactor3 = peripheral.wrap("")
- reactor4 = peripheral.wrap("")
- --[[
- Variables for the main program, please do not touch
- ]]
- x,y = term.getSize()
- running = false
- index = 1
- default = {
- background = "black",
- textC = "white"
- }
- button = {
- button1 = {text = "Back",bx = 1, by = y},
- button2 = {text = "Select", bx = math.floor((x/2)-(string.len("Select")/2)), by = y},
- button3 = {text = "Next",bx = x-string.len("Next")+1, by = y}
- }
- buttonSize = table.getn(button)
- local function drawButton(state1,state2,state3,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
- 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])
- 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
- term.setBackgroundColour(colours[default.background])
- end
- local function flashButton(b)
- if b == 1 then drawButton(true,false,false,"green") end
- if b == 2 then drawButton(false,true,false,"green") end
- if b == 3 then drawButton(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)
- term.setCursorPos(x,y)
- term.setBackgroundColour(colours.red)
- for i = 1,25 do
- print(" ")
- end
- term.setBackgroundColour(colours.green)
- for i = 1,val do
- print(" ")
- end
- term.setBackgroundColour(colours[default.background])
- end
- function printReactor()
- while running do
- per1 = math.floor(((cur1/max)*100)/25)
- term.setCursorPos(1,2)
- term.write("RF Stored: ")
- printBar(1+string.len("RF Stored: "),2,per1)
- end
- end
- function gui()
- while running do
- if index == 1 then
- drawButton(false,true,true)
- elseif
- drawButton(true,true,false)
- else
- drawButton(true,true,true)
- 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 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 then
- flashButton(2)
- elseif param2 >= button.button3.bx and param2 <= (button.button3.bx + #button.button3.text) and param3 == button.button3.by and index ~= 4 then
- flashButton(3)
- index = index + 1
- clearScreen()
- end
- elseif event == "key" then
- if param1 == keys.y then
- running = false
- shell.run("edit main")
- end
- end
- term.setCursorPos(1,y)
- term.clearLine()
- end
- end
- parallel.waitForAny(gui,printReactor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement