Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ VARIABLES ]]--
- local x, y = term.getSize()
- local SolarPanelsStat = true
- local QuarryStat = false
- local rSide = "left"
- local selectedItem = 1
- local inMainMenu = true
- --[[ HANDLER FUNCTIONS ]]--
- function Quarry()
- QuarryStat = not QuarryStat
- end
- --[[ FUNCTIONS ]]--
- function Clear()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1, 1)
- end
- function writeSolarPanelsStatus()
- term.setCursorPos(x/1.3, 2)
- if SolarPanelsStat == true then
- term.setTextColor(colors.green)
- print("On ")
- elseif SolarPanelsStat == false then
- term.setTextColor(colors.red)
- print("Off")
- end
- end
- function writeStats()
- writeSolarPanelsStatus()
- end
- function ReceiveStats()
- rednet.open("left")
- local event, id, msg = os.pullEvent("rednet_message")
- if msg == "SolarPanelsOn" then
- SolarPanelsStat = true
- elseif msg == "SolarPanelsOff" then
- SolarPanelsStat = false
- elseif msg == "QuarryOn" then
- QuarryStat = true
- elseif msg == "QuarryOff" then
- QuarryStat = false
- end
- end
- function CheckTime()
- term.setCursorPos(x/2-4.5, 1)
- local time = os.time()
- time = textutils.formatTime(time, false)
- term.setTextColor(colors.white)
- print(time)
- end
- function printDisplay()
- for i=1 , #display do
- term.setCursorPos(x/2, i+1)
- term.setTextColor(colors.white)
- print(display[i].text)
- term.setCursorPos(x/.5, 3)
- writeStats()
- end
- end
- function printMenu(menu)
- for i=1, #menu do
- if i == selectedItem then
- print(">> "..menu[i].text)
- else
- print(" "..menu[i].text)
- end
- end
- end
- function onItemSelected(menu)
- menu[selectedItem].handler()
- end
- function onKeyPressed(key, menu)
- if key == keys.enter then
- onItemSelected(menu)
- elseif key == keys.up then
- if selectedItem > 1 then
- selectedItem = selectedItem - 1
- end
- elseif key == keys.down then
- if selectedItem < #menu then
- selectedItem = selectedItem + 1
- end
- end
- end
- function writeQuarryStats()
- term.setCursorPos(x/4, 2)
- if QuarryStat == true then
- term.setTextColor(colors.green)
- print("On ")
- elseif QuarryStat == false then
- term.setTextColor(colors.red)
- print("Off")
- end
- end
- function writeMenuStats()
- writeQuarryStats()
- end
- function main()
- while inMainMenu do
- Clear()
- term.setTextColor(colors.white)
- term.setCursorPos(1, 2)
- printMenu(mainMenu)
- writeMenuStats()
- local event,key = os.pullEvent("key")
- onKeyPressed(key, mainMenu)
- end
- end
- function PrintFinalStats()
- while true do
- CheckTime()
- printDisplay()
- ReceiveStats()
- end
- end
- function Parallel1()
- parallel.waitForAny(PrintFinalStats(),main())
- end
- function Parallel2()
- parallel.waitForAny(main(), PrintFinalStats())
- end
- --[[ TABLES ]]--
- mainMenu = {
- [1] = {text = "Quarry", handler = Quarry}
- }
- display = {
- [1] = {text = "SolarPanels"}
- }
- --[[ MAIN CODE ]]--
- Clear()
- parallel.waitForAny(Parallel1, Parallel2)
Advertisement
Add Comment
Please, Sign In to add comment