Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = require("term")
- local fs = require("filesystem")
- local comp = require("component")
- local computer = require("computer")
- local key = require("keyboard")
- local event = require("event")
- local gpu = comp.gpu
- resx, resy = gpu.getResolution()
- halfresx = math.floor(resx/2)
- halfresy = math.floor(resy/2)
- quarterresx = math.floor(halfresx/2)
- quarterresy = math.floor(halfresy/2)
- src = 0
- function printMenu()
- term.clear()
- if src == 0 then
- term.setCursor(quarterresx+2,halfresy-2)
- print("[Continue Normally]")
- else
- term.setCursor(quarterresx+3,halfresy-2)
- print("Continue Normally")
- end
- if src == 1 then
- term.setCursor(quarterresx+2,halfresy) -- Will need to change this
- print("[Display Information]")
- else
- term.setCursor(quarterresx+3,halfresy)
- print("Display Information")
- end
- if src == 2 then
- term.setCursor(quarterresx+2,halfresy+2)
- print("[Shutdown Computer]")
- else
- term.setCursor(quarterresx+3,halfresy+2)
- print("Shutdown Computer")
- end
- _,_,_,kn = event.pull("key_down")
- if kn == 208 then
- if src == 0 then
- src = src +1
- elseif src == 1 then
- src = src +1
- end
- elseif kn == 200 then
- if src == 1 then
- src = src -1
- elseif src == 2 then
- src = src -1
- end
- end
- if kn == 28 then
- if src == 0 then
- term.clear()
- os.exit()
- elseif src == 1 then
- printInfo()
- elseif src == 2 then
- computer.shutdown()
- end
- end
- printMenu()
- end
- function printInfo()
- id = event.timer(0.5,printMem,math.huge)
- term.clear()
- term.setCursor(quarterresx+2,halfresy-2)
- print("Free Memory: " ..computer.freeMemory()/1024 .. "kb")
- term.setCursor(quarterresx+2,halfresy)
- print("Installed memory: " .. computer.totalMemory()/1024 .. "kb")
- term.setCursor(quarterresx+5,halfresy+2)
- event.pull("key_down")
- event.cancel(id)
- end
- function printMem()
- term.setCursor(quarterresx+2,halfresy-2)
- print("Free Memory: " .. computer.freeMemory()/1024 .. "kb")
- end
- printMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement