Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- --Vars----------------------------------------------------------------
- local rng = true
- local Exit = nil
- local cm = 1
- local w,h = term.getSize()
- local conf = A.getT("os/files/config")
- local Ctimer = nil
- local m = {"Reboot ","Shutdown ","Termanate ","Login In ","Create User","Delete User","Edit Pass "}
- --Buffers-------------------------------------------------------------
- local bgb = buf.createBuffer() --background buffer
- ----------------------------------------------------------------------
- local function dtable(t)
- for v,k in ipairs(t) do
- if cm==v then
- buf.wCentered(bgb,"[ ]",math.floor((h/2-(#t/2)))+v,colors.red,colors.black)
- buf.wCentered(bgb,k,math.floor((h/2-(#t/2)))+v,colors.red,colors.black)
- else
- buf.wCentered(bgb,k,math.floor((h/2-(#t/2)))+v,colors.red,colors.black)
- end
- end
- end
- local function dm()
- buf.drawFilledBox(bgb,1,2,w,h-1,colors.black)
- dtable(m)
- buf.drawBuffer(bgb)
- A.Time(w-4,h,colors.gray,colors.white)
- end
- local function Startdm()
- buf.tc(colors.red)
- buf.bc(colors.black)
- buf.clsB(bgb,colors.black,colors.red)
- buf.clsLx(bgb,1,colors.gray)
- buf.clsLx(bgb,h,colors.gray)
- buf.wCentered(bgb,"Admin Console",1,colors.white,colors.gray)
- buf.wLeft(bgb," Version: "..conf["VER"],h,colors.white,colors.gray)
- end
- local function WriteLeft(y,str)
- term.setCursorPos(2,y)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.red)
- term.write(str)
- end
- --Main content tables-------------------------------------------------
- local f = {}
- table.insert(f,function() os.reboot() end)
- table.insert(f,function() os.shutdown() end)
- table.insert(f,function() error("Terminated") end)
- table.insert(f,function() Exit = "login"; rng = false end)
- table.insert(f,function()
- local NUser = A.userin(2,2,4)
- if fs.exists("os/users/"..NUser) == false then
- fs.copy("os/files/UserData","os/users/"..NUser)
- end
- dm()
- WriteLeft(3,"Created Account: "..NUser)
- end)
- table.insert(f,function()
- local NUser = A.userin(2,2,4)
- if fs.exists("os/users/"..NUser) and NUser~="Admin" then
- fs.delete("os/users/"..NUser)
- end
- dm()
- WriteLeft(3,"Deleted Account: "..NUser)
- end)
- table.insert(f,function()
- local src = "os/users/Admin/Uconfig"
- local Aconf = A.getT(src)
- local Npass = A.userin(2,2,4)
- if Npass ~= Aconf["PW"] then
- Aconf["PW"] = Npass
- A.setT(src,Aconf)
- end
- dm()
- WriteLeft(3,"Saved Password: "..Npass)
- end)
- -- table.insert(f,function() end) --used for copy and paste for new meun options
- --function that must go after the table setup
- local function runFunction()
- for v,k in ipairs(f) do
- if cm == v then
- k()
- end
- end
- end
- --Main----------------------------------------------------------------
- local function main()
- --setup functions
- Startdm()
- dm()
- Ctimer = os.startTimer(.1)
- --main loop
- while rng do
- local arg = { os.pullEvent() }
- if arg[1]=="timer" and arg[2]==Ctimer then
- A.Time(w-4,h,colors.gray,colors.white)
- Ctimer = os.startTimer(.01)
- elseif arg[1]=="key" then
- local function up()
- if cm==1 then
- cm=#m
- else
- cm = cm-1
- end
- dm()
- end
- local function down()
- if cm==#m then
- cm=1
- else
- cm = cm+1
- end
- dm()
- end
- if arg[2] == 208 then
- down()
- elseif arg[2] == 205 then
- down()
- elseif arg[2] == 200 then
- up()
- elseif arg[2] == 203 then
- up()
- elseif arg[2] == 28 then
- runFunction()
- end
- end
- end
- end
- local ok, err = pcall(main)
- if not ok then
- if err == "manage:48: Terminated" then
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.red)
- term.clear()
- term.setCursorPos(1,1)
- print("Terminated")
- term.setTextColor(colors.white)
- else
- A.Error(err)
- end
- end
- if Exit == "login" then
- shell.run("os/login")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement