Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(1, 1)
- term.clear()
- local react = peripheral.wrap("back")
- local termX, termY = term.getSize()
- local selector = 1
- 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 function menuDraw(selected)
- local yPos = (termY - #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)
- term.write(" " .. data.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
- 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
- if selector == 1 then
- if react.getActive() == true then
- react.setActive(false)
- os.reboot()
- elseif react.getActive() == false then
- react.setActive(true)
- os.reboot()
- end
- elseif selector == 2 then
- write(react.getFuelAmount() .. "/" .. react.getFuelAmountMax())
- sleep(2)
- os.reboot()
- elseif selector == 3 then
- write(react.getEnergyStored() .. "/10,000,000")
- sleep(2)
- os.reboot()
- elseif selector == 4 then
- write(tostring(react.getFuelConsumedLastTick()))
- sleep(2)
- os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement