Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Variables
- local osVer = "Alpha 1.0"
- local w,h = term.getSize()
- local brunning = true
- local slc = 0
- local _mtext = 1
- local _mback = 128
- --Tables
- local menu = {
- [" "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 13; y = 1; cmd = function() slc = 1 end };
- [" "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 13; y = 2; cmd = function() end };
- [" Programs > "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 13; y = 3; cmd = function() end };
- [" Settings > "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 13; y = 4; cmd = function() end };
- [" Lua Prompt> "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 13; y = 5; cmd = function() end };
- [" Quit > "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 13; y = 6; cmd = function() term.setBackgroundColor(colors.black) term.setCursorPos(1,1) term.clear() brunning = false end };
- [" Shutdown > "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 13; y = 7; cmd = function() os.shutdown() end };
- [" Logoff > "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 13; y = 8; cmd = function() end };
- [" Reboot > "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 13; y = 9; cmd = function() os.reboot() end };
- [" "] = {tcol = _mtext; bcol = _mback; x = 1; xx = 13; y = 10; cmd = function() end };
- }
- --Functions
- local function tb_Draw()
- term.setCursorPos(1,1)
- term.setBackgroundColor(8)
- term.setTextColor(1)
- term.clearLine()
- print("[ Begin ]")
- term.setCursorPos(math.floor(w)-# osVer, 1)
- print(osVer)
- end
- local function drawMenu()
- for k,v in pairs(menu) do
- term.setBackgroundColor(v.bcol)
- term.setTextColor(v.tcol)
- term.setCursorPos(v.x, v.y)
- print(k)
- end
- end
- local function menuClick()
- for k,v in pairs(menu) do
- local e = {os.pullEvent()}
- if e[1] == "mouse_cllick" then
- if e[2] == 1 then
- if e[3] >= v.x and e[3]<= v.xx and e[4] == v.y then
- v.cmd()
- else slc = 0
- end
- end
- end
- end return true
- end
- local function clear(bcol)
- term.setBackgroundColor(bcol)
- term.clear()
- end
- --Main Code
- clear(colors.black)
- tb_Draw()
- while brunning do
- e = {os.pullEvent()}
- if slc == 0 then
- clear(colors.black)
- tb_draw()
- if e[1] == "mouse_cllick" then
- if e[2] == 1 then
- if e[3] >= 1 and e[3]<= 13 and e[4] == 1 then
- slc = 1
- drawMenu()
- end
- end
- end
- elseif slc == 1 then
- drawMenu()
- menuClick()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement