Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- react = peripheral.wrap("back")
- term.clear()
- local menu_options = {
- [1] = {text="Reactor ON/OFF Toggle", color=colors.blue},
- [2] = {text="Reactor Fuel Level", color=colors.black},
- [3] = {text="Reactor Power Level", color=colors.orange},
- [4] = {text="Reactor Fuel Usage (Consumed Last Tick)", color=colors.cyan}
- }
- local termX, termY = term.getSize()
- local function menuDraw(selected)
- local yPos = termY/2 - #menu_options/2
- for index, data in pairs(menu_options) do
- menu_options[index].bounds = {
- x1 = termX/2 - (#data.text+4)/2,
- x2 = termX/2 + (#data.text+4)/2,
- y = yPos
- }
- term.setTextColor(data.color)
- term.setCursorPos(data.bounds.x1, data.bounds.y)
- local text =
- index==selected and " "..data.text.." " or
- " "..data.text.." "
- term.write(text)
- yPos=yPos+1
- end
- end
- local function checkClick(x,y)
- for index, data in pairs(menu_options) do
- if x>= data.bounds.x1 and x<= data.bounds.x2 and y==data.bounds.y then
- return index
- end
- end
- return false
- end
- term.setBackgroundColor(colors.grey)
- term.clear()
- local selector = 1
- while true do
- menuDraw(selector)
- local e = {os.pullEvent()}
- if e[1] == "mouse_click" then
- local value = checkClick(e[3], e[4])
- if value then
- selector = value
- break
- end
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- if selector == 1 then
- if react.getActive() == true then
- react.setActive(false)
- shell.run("startup")
- elseif react.getActive() == false then
- react.setActive(true)
- shell.run("startup")
- end
- elseif selector == 2 then
- write(react.getFuelAmount().."/"..react.getFuelAmountMax())
- sleep(2)
- shell.run("startup")
- elseif selector == 3 then
- write(react.getEnergyStored().."/10,000,000")
- sleep(2)
- shell.run("startup")
- elseif selector == 4 then
- write(react.getFuelConsumedLastTick())
- sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement