Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getT(src)
- local file = fs.open(src,"r")
- local data = file.readAll()
- file.close()
- local conf = textutils.unserialize(data)
- return conf
- end
- function setT(src,save)
- local file = fs.open(src,"w")
- file.write(textutils.serialize(save))
- file.close()
- end
- --vars------------------------------------------------------------------
- local w,h = term.getSize()
- local conf = getT("os/files/config")
- local Cpath = nil
- local User = nil
- local code = conf["CODE"]
- local ver = conf["VER"]
- local Exit = nil
- ---MEUNS-------------------------------------------------------------------
- function LoadConf(Uin)
- User = Uin
- Cpath = "os/users/"..User.."/Uconfig"
- conf = getT(Cpath)
- end
- function ExitIS(Set,value)
- if Set then
- Exit = value
- else
- return Exit
- end
- end
- function RCpath()
- return Cpath
- end
- function RUser()
- return User
- end
- --Load meuns--
- local function meun1()
- buf.bc(conf["SMC"])
- buf.tc(conf["SMTC"])
- xy = buf.getSizeBuff(bmeun1)
- buf.pos(1,1)
- buf.bWriteL(bmeun1,"+==========+")
- buf.pos(1,2)
- buf.bWriteL(bmeun1,"| Sign Out |")
- buf.pos(1,3)
- buf.bWriteL(bmeun1,"| ShutDown |")
- buf.pos(1,4)
- buf.bWriteL(bmeun1,"| ReBoot |")
- buf.pos(1,5)
- buf.bWriteL(bmeun1,"| Manage |")
- buf.pos(1,6)
- buf.bWriteL(bmeun1,"| Config |")
- buf.pos(1,7)
- buf.bWriteL(bmeun1,"+==========+")
- end
- local function meun2()
- buf.bc(conf["SMC"])
- buf.tc(conf["SMTC"])
- buf.pos(1,1)
- buf.bWriteL(bmeun2,"+==========+")
- buf.pos(1,2)
- buf.bWriteL(bmeun2,"| Add Icon |")
- buf.pos(1,3)
- buf.bWriteL(bmeun2,"| New Prog.|")
- buf.pos(1,4)
- buf.bWriteL(bmeun2,"| New Icon |")
- buf.pos(1,5)
- buf.bWriteL(bmeun2,"| Help |")
- buf.pos(1,6)
- buf.bWriteL(bmeun2,"+==========+")
- end
- local function meun3()
- buf.bc(conf["SMC"])
- buf.tc(conf["SMTC"])
- buf.pos(1,1)
- buf.bWriteL(bmeun3,"+============+")
- buf.pos(1,2)
- buf.bWriteL(bmeun3,"| Change Img |")
- buf.pos(1,3)
- buf.bWriteL(bmeun3,"| Programs |")
- buf.pos(1,4)
- buf.bWriteL(bmeun3,"| Remove |")
- buf.pos(1,5)
- buf.bWriteL(bmeun3,"+============+")
- end
- local function meun4()
- buf.bc(conf["SMC"])
- buf.tc(conf["SMTC"])
- buf.pos(1,1)
- buf.bWriteL(bmeun4,"+========+")
- buf.pos(1,2)
- buf.bWriteL(bmeun4,"| Edit |")
- buf.pos(1,3)
- buf.bWriteL(bmeun4,"| Remove |")
- buf.pos(1,4)
- buf.bWriteL(bmeun4,"+========+")
- end
- local function meun5()
- buf.bc(conf["SMC"])
- buf.tc(conf["SMTC"])
- buf.pos(1,1)
- buf.bWriteL(bmeun5,"+==========+")
- buf.pos(1,2)
- buf.bWriteL(bmeun5,"| Sign Out |")
- buf.pos(1,3)
- buf.bWriteL(bmeun5,"| ShutDown |")
- buf.pos(1,4)
- buf.bWriteL(bmeun5,"| ReBoot |")
- buf.pos(1,5)
- buf.bWriteL(bmeun5,"| Back |")
- buf.pos(1,6)
- buf.bWriteL(bmeun5,"+==========+")
- end
- local function meun6()
- buf.bc(conf["SMC"])
- buf.tc(conf["SMTC"])
- buf.pos(1,1)
- buf.bWriteL(bmeun6,"+===========+")
- buf.pos(1,2)
- buf.bWriteL(bmeun6,"| Add Image |")
- buf.pos(1,3)
- buf.bWriteL(bmeun6,"+===========+")
- end
- local function meun7()
- buf.bc(conf["SMC"])
- buf.tc(conf["SMTC"])
- buf.pos(1,1)
- buf.bWriteL(bmeun7,"+==========+")
- buf.pos(1,2)
- buf.bWriteL(bmeun7,"| Desktop |")
- buf.pos(1,3)
- buf.bWriteL(bmeun7,"| Public |")
- buf.pos(1,4)
- buf.bWriteL(bmeun7,"| Private |")
- buf.pos(1,5)
- buf.bWriteL(bmeun7,"| PasteBin |")
- buf.pos(1,6)
- buf.bWriteL(bmeun7,"+==========+")
- end
- --handel meuns--s
- function createbufs()
- createFigBufs()
- bmeun = buf.createBuffer()
- bmeun1 = buf.createBuffer(12,7)
- bmeun2 = buf.createBuffer(12,6)
- bmeun3 = buf.createBuffer(14,5)
- bmeun4 = buf.createBuffer(10,4)
- bmeun5 = buf.createBuffer(12,6)
- bmeun6 = buf.createBuffer(13,3)
- bmeun7 = buf.createBuffer(12,6)
- binput = buf.createBuffer(24,3)
- buf.drawImage(binput,1,1,"os/images/input")
- meun1()
- meun2()
- meun3()
- meun4()
- meun5()
- meun6()
- meun7()
- end
- function reloadMeuns()
- conf = A.getT(Cpath)
- meun1()
- meun2()
- meun3()
- meun4()
- meun5()
- meun6()
- meun7()
- end
- --Retun Meuns--
- function Rmeun()
- return bmeun
- end
- --Draw Meuns--
- function dmeun(i,x,y)
- conf = A.getT(Cpath)
- buf.clsB(bmeun)
- buf.drawImage(bmeun,x,y,i)
- buf.pos(1,1)
- buf.bc(conf["MC"])
- buf.clsLx(bmeun)
- buf.tc(conf["MTC"])
- buf.bWriteL(bmeun," (start)")
- buf.pos(52-(2+#ver),1)
- buf.bWriteL(bmeun,"V:"..ver)
- buf.pos(1,19)
- buf.clsLx(bmeun)
- buf.bWriteL(bmeun,"Made By: SuperKH")
- buf.pos(1,2)
- end
- function dmeun1()
- buf.drawBuffer(bmeun1,1,2)
- end
- function dmeun2(x,y)
- local xy = {x,y}
- if y==1 then
- xy[2]=2
- end
- if y>=19-6 then
- xy[2]=19-6
- end
- if x>=52-12 then
- xy[1]=52-12
- end
- buf.drawBuffer(bmeun2,xy[1],xy[2])
- return xy
- end
- function dmeun3(xy)
- if xy[2]<14 then
- xy[2]=xy[2]+5
- else
- xy[2]=xy[2]-5
- end
- buf.drawBuffer(bmeun3,xy[1],xy[2])
- end
- function dmeun4(x,y)
- buf.drawBuffer(bmeun4,x,y)
- end
- function dmeun5()
- buf.drawBuffer(bmeun5,1,2)
- end
- function dmeun6(x,y)
- if y<=1 then
- y=2
- end
- if y>=h-3 then
- y=h-3
- end
- if x>=w-12 then
- x=w-12
- end
- buf.drawBuffer(bmeun6,x,y)
- return x,y
- end
- function dmeun7(xy)
- buf.drawBuffer(bmeun7,xy[1],xy[2])
- end
- --Fig Meuns---------------------------------------------------------------------
- --Load Meuns--
- function cline()
- local tColorLookup = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768}
- x = 1
- y = 1
- for v,k in ipairs(tColorLookup) do
- buf.pos(x,y)
- buf.bc(k)
- buf.bWrite(bcline," ")
- x=x+1
- end
- end
- --Handel Meuns--
- function createFigBufs()
- bfig = buf.createBuffer()
- bcline = buf.createBuffer(16,1)
- cline()
- end
- --Retun Meuns--
- function RFmeun()
- return bfig
- end
- --Draw Meuns--
- function dfig()
- --set un back backgrounds
- conf = A.getT(Cpath)
- buf.bc(conf["CBC"])
- buf.clsB(bfig)
- buf.drawImage(bfig,1,1,conf["CBI"])
- buf.pos(1,1)
- buf.bc(conf["MC"])
- buf.clsLx(bfig)
- buf.tc(conf["MTC"])
- buf.bWriteL(bfig," (start)")
- buf.pos(52-(2+#ver),1)
- buf.bWriteL(bfig,"V:"..ver)
- buf.pos(1,19)
- buf.clsLx(bfig)
- buf.bWriteL(bfig,"Made By: SuperKH")
- buf.pos(1,2)
- end
- function dcline(x,y)
- buf.drawBuffer(bcline,x,y)
- end
- -------------------------------------------------------------------------
- function Error(err)
- local function Cwrite(y,words,Tc,Bc)
- local Tc = Tc or term.getTextColor()
- local cpos = term.getCursorPos()
- local x = math.ceil((w/2)-(#words/2)+1)
- local y = y or cpos[2]
- local Bc = Bc or term.getBackgroundColor()
- term.setBackgroundColor(Bc)
- term.setTextColor(Tc)
- term.setCursorPos(x,y)
- write(words)
- end
- local function clsX(y,c,w,s,e)
- local ccolor = term.getBackgroundColor()
- local c = c or ccolor
- local cpos = {term.getCursorPos()}
- local y = y or cpos[2]
- local w = w or " "
- local Start = s or 1
- local End = e or w
- term.setBackgroundColor(c)
- for i=Start, End do
- term.setCursorPos(i,y)
- write(w)
- end
- end
- local function clsY(x,c,w,s,e)
- local ccolor = term.getBackgroundColor()
- local c = c or ccolor
- local cpos = {term.getCursorPos()}
- local x = x or cpos[1]
- local w = w or " "
- local Start = s or 1
- local End = e or h
- term.setBackgroundColor(c)
- for i=Start, End do
- term.setCursorPos(x,i)
- write(w)
- end
- end
- local function pString(s)
- s = s .. " "
- local function sString(x)
- local t = {}
- while true do
- local y = string.find(x," ")
- if y == nil then
- table.insert(t,x)
- return t
- end
- table.insert(t,string.sub(x,1,y))
- x = string.sub(x,y+1)
- end
- end
- local t = sString(s)
- local newT = {}
- local size = 0
- local str = ""
- for v,k in ipairs(t) do
- if size+#k<=48 then
- str = str..k
- size = #str
- if v==#t then
- table.insert(newT,str)
- end
- else
- table.insert(newT,str)
- size = 0
- str = ""
- --
- str = str..k
- size = #str
- if v==#t then
- table.insert(newT,str)
- end
- end
- end
- return newT
- end
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.blue)
- term.clear()
- term.setCursorPos(1,1)
- write("+")
- clsX(1,colors.blue,"-",2,w-1)
- write("+")
- clsY(1,colors.blue,"|",2,h-1)
- clsY(w,colors.blue,"|",2,h-1)
- term.setCursorPos(1,h)
- write("+")
- clsX(h,colors.blue,"-",2,w-1)
- write("+")
- Cwrite(2,"Error:")
- clsX(3,colors.blue,"-",2,w-1)
- local errorT = pString(err)
- y = 5
- for v,k in ipairs(errorT) do
- term.setCursorPos(1,y)
- Cwrite(y,k)
- y=y+1
- end
- term.setCursorPos(2,h-1)
- -----------------------------------------------------------------------
- if not fs.exists("os/files/ErrorLog") then
- local f = fs.open("os/files/ErrorLog","w")
- f.writeLine("---------------------------------------------------")
- f.writeLine(" Thank You For Using SuperOS! ")
- f.writeLine(" ------------------------- ")
- f.writeLine(" Sorry For All The Inconveniencses! ")
- f.writeLine(" If Errors Continually Accor Please Upload This ")
- f.writeLine(" File To PasteBin And Then Email Me The Link To ")
- f.writeLine("' ~noobykyle@gmail.com '")
- f.writeLine("---------------------------------------------------")
- f.close()
- end
- local f = fs.open("os/files/ErrorLog","a")
- f.writeLine(err)
- f.close()
- end
- function pastebin(sCode,path)
- local sFile = path
- local sPath = sFile
- if fs.exists( sPath ) then
- fs.delete(sPath)
- end
- --gets the contents from pastebin
- local function get(paste)
- local response = http.get(
- "http://pastebin.com/raw/"..textutils.urlEncode( paste )
- )
- if response then
- local sResponcse = response.readAll()
- response.close()
- return sResponcse
- else
- error(paste)
- end
- end
- local res = get(sCode)
- if res then
- local file = fs.open( sPath, "w" )
- file.write( res )
- file.close()
- end
- end
- function checkupdate()
- pastebin("L2xbGSm5","os/files/update")
- local src = "os/files/update"
- local file = fs.open(src,"r")
- local data = file.readAll()
- file.close()
- if data ~= code then
- return true
- else
- return false
- end
- end
- function check2()
- local bufC = buf.createBuffer()
- buf.bc(colors.black)
- buf.tc(colors.white)
- buf.clsB(bufC)
- buf.drawImage(bufC,1,1,"os/images/update")
- buf.pos(15,6)
- buf.bc(colors.blue)
- buf.bWriteL(bufC,"Do you Wish to Update?")
- buf.pos(17,8)
- buf.bc(colors.green)
- buf.bWriteL(bufC,"YES!")
- buf.pos(30,8)
- buf.bc(colors.red)
- buf.bWriteL(bufC,"NO!")
- buf.pos(1,1)
- buf.drawBuffer(bufC)
- while true do
- local arg = { os.pullEvent() }
- if arg[1]=="mouse_click" then
- if arg[2]==1 then
- if arg[3]>=14 and arg[3]<=24 then
- if arg[4]>=8 and arg[4]<=11 then
- return true
- end
- elseif arg[3]>=26 and arg[3]<=36 then
- if arg[4]>=8 and arg[4]<=11 then
- return false
- end
- end
- end
- elseif arg[1]=="key" then
- if arg[2]==28 then
- return true
- end
- end
- end
- end
- function userin(x,y,o)
- buf.drawBuffer(binput,x,y)
- term.setCursorPos(x+1,y+1)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- if o==0 then
- write("Program Name: ")
- local input = read()
- input = input
- return input
- elseif o==1 then
- write("../icons/")
- local input = read()
- input = "os/images/icons/"..input
- return input
- elseif o==2 then
- local confl = getT("os/users/Admin/Uconfig")
- pass = confl["PW"]
- write(" Pass:")
- local input = read("*")
- if input == pass then
- return true
- else
- return false -- change to false to disable
- end
- elseif o==3 then
- write("../images/")
- local input = read()
- input = "os/images/"..input
- return input
- elseif o==4 then
- write("User: ")
- local input = read()
- return input
- end
- end
- function Time(x,y,bc,tc)
- local mTime = true
- local tTime = textutils.formatTime(os.time(),mTime)
- term.setBackgroundColor(bc)
- term.setTextColor(tc)
- term.setCursorPos(w-#tTime+1,y)
- write(tTime)
- term.setCursorPos(2,2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement