Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- client="Update Client"
- server="Update Server"
- self="Update Self"
- clientsel="* Update Client *"
- serversel="* Update Server *"
- selfsel="* Update Self *"
- uptx="Checking for update..."
- futx="Found Update! Press Y to update or N to cancel"
- lvtx="Script already at latest version!"
- cutx="Updating..."
- catx="Canceled!"
- extxt=" Press Delete To Exit! "
- cuctx="Updated!"
- clgtx="Closing..."
- cldtx="Closed."
- clientcode="g7AmTvM8"
- servercode="43NXRhFi"
- selfcode="6UwqyDkP"
- selected=1
- shell.run("clear")
- path = shell.resolve("")
- screenx,screeny=term.getSize()
- color = colors.red
- incolor = colors.blue
- function setPos(x,y)
- term.setCursorPos(x,y)
- end
- function drawBox(mask,xmin,ymin,xmax,ymax)
- if term.isColor() then
- term.setBackgroundColor(color)
- screenx,screeny=term.getSize()
- setPos(xmin,ymin)
- for i=1,(xmax+1)-xmin do
- write(" ")
- setPos((xmin-1)+i,ymax)
- write(" ")
- setPos(xmin+i,ymin)
- end
- term.setBackgroundColor(incolor)
- for i=2,ymax-1 do
- for j=1,(xmax+2)-xmin do
- setPos(xmin+j,(ymin-1)+i)
- write(" ")
- end
- end
- term.setBackgroundColor(color)
- for i=1,((ymax+1)-ymin)-2 do
- setPos(xmin,ymin+i)
- write(" ")
- setPos(xmax,ymin+i)
- write(" ")
- end
- term.setBackgroundColor(incolor)
- else
- screenx,screeny=term.getSize()
- setPos(xmin,ymin)
- for i=1,(xmax+1)-xmin do
- write(mask)
- setPos((xmin-1)+i,ymax)
- write(mask)
- setPos(xmin+i,ymin)
- end
- for i=1,((ymax+1)-ymin)-2 do
- setPos(xmin,ymin+i)
- write(mask)
- setPos(xmax,ymin+i)
- write(mask)
- end
- end
- end
- function draw()
- screenx,screeny=term.getSize()
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- if term.isColor() then
- term.setCursorPos(screenx-5,3)
- if term.isColor() then term.setBackgroundColor(colors.orange) end
- write("Exit")
- if term.isColor() then term.setBackgroundColor(incolor) end
- end
- if selected==1 then
- term.setCursorPos((screenx/2)-(string.len(clientsel)/2),screeny/3-2)
- write(clientsel)
- term.setCursorPos((screenx/2)-(string.len(server)/2),screeny/3*2-2)
- write(server)
- term.setCursorPos((screenx/2)-(string.len(self)/2),screeny/3*3-3)
- write(self)
- else if selected==2 then
- term.setCursorPos((screenx/2)-(string.len(client)/2),screeny/3-2)
- write(client)
- term.setCursorPos((screenx/2)-(string.len(serversel)/2),screeny/3*2-2)
- write(serversel)
- term.setCursorPos((screenx/2)-(string.len(self)/2),screeny/3*3-3)
- write(self)
- else if selected==3 then
- term.setCursorPos((screenx/2)-(string.len(client)/2),screeny/3-2)
- write(client)
- term.setCursorPos((screenx/2)-(string.len(server)/2),screeny/3*2-2)
- write(server)
- term.setCursorPos((screenx/2)-(string.len(selfsel)/2),screeny/3*3-3)
- write(selfsel)
- end
- end
- end
- if term.isColor() then
- term.setBackgroundColor(color)
- end
- term.setCursorPos((screenx/2)-(string.len(extxt)/2),screeny)
- write(extxt)
- if term.isColor() then
- term.setBackgroundColor(incolor)
- end
- end
- draw()
- function checkForUpdate(pbcode,scname)
- atf=false
- if fs.exists(path.."/"..scname) then
- h=http.get("http://pastebin.com/raw.php?i="..pbcode)
- hsc=h.readAll()
- c=fs.open(path.."/"..scname,"r")
- csc=c.readAll()
- if hsc==csc then atf=false else atf=true end
- h.close()
- c.close()
- return atf
- else
- return true
- end
- end
- function updateclient()
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(uptx)/2),screeny/2)
- write(uptx)
- if checkForUpdate(clientcode,"chat") then
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(futx)/2)+1,screeny/2)
- write(futx)
- while slup==nil do
- e,par1=os.pullEvent()
- if e == "key" then
- if tostring(par1) == "21" then
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(cutx)/2),screeny/2)
- write(cutx)
- h=http.get("http://pastebin.com/raw.php?i=g7AmTvM8")
- hsc=h.readAll()
- c=fs.open(path.."/chat","w")
- c.write(hsc)
- h.close()
- c.close()
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(cuctx)/2),screeny/2)
- write(cuctx)
- sleep(2.5)
- return
- else if tostring(par1) == "49" then
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(catx)/2),screeny/2)
- write(catx)
- sleep(2.5)
- return
- end
- end
- end
- end
- else
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(lvtx)/2),screeny/2)
- write(lvtx)
- sleep(1.5)
- end
- end
- function updateserver()
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(uptx)/2),screeny/2)
- write(uptx)
- if checkForUpdate(servercode,"server") then
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(futx)/2)+1,screeny/2)
- write(futx)
- while slup==nil do
- e,par1=os.pullEvent()
- if e == "key" then
- if tostring(par1) == "21" then
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(cutx)/2),screeny/2)
- write(cutx)
- h=http.get("http://pastebin.com/raw.php?i=43NXRhFi")
- hsc=h.readAll()
- c=fs.open(path.."/server","w")
- c.write(hsc)
- h.close()
- c.close()
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(cuctx)/2),screeny/2)
- write(cuctx)
- sleep(2.5)
- return
- else if tostring(par1) == "49" then
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(catx)/2),screeny/2)
- write(catx)
- sleep(2.5)
- return
- end
- end
- end
- end
- else
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(lvtx)/2),screeny/2)
- write(lvtx)
- sleep(1.5)
- end
- end
- function updateself()
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(uptx)/2),screeny/2)
- write(uptx)
- if checkForUpdate(selfcode,"updater") then
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(futx)/2)+1,screeny/2)
- write(futx)
- while slup==nil do
- e,par1=os.pullEvent()
- if e == "key" then
- if tostring(par1) == "21" then
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(cutx)/2),screeny/2)
- write(cutx)
- h=http.get("http://pastebin.com/raw.php?i=6UwqyDkP")
- hsc=h.readAll()
- c=fs.open(path.."/updater","w")
- c.write(hsc)
- h.close()
- c.close()
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(cuctx)/2),screeny/2)
- write(cuctx)
- sleep(2.5)
- exitscr()
- sleep(2.5)
- term.setBackgroundColor(colors.black)
- shell.run("clear")
- error()
- return
- else if tostring(par1) == "49" then
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(catx)/2),screeny/2)
- write(catx)
- sleep(2.5)
- return
- end
- end
- end
- end
- else
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(lvtx)/2),screeny/2)
- write(lvtx)
- sleep(1.5)
- end
- end
- function exitscr()
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(clgtx)/2),screeny/2)
- write(clgtx)
- sleep(1.5)
- shell.run("clear")
- drawBox("#",1,1,screenx,screeny)
- term.setCursorPos((screenx/2)-(string.len(cldtx)/2),screeny/2)
- write(cldtx)
- sleep(1.5)
- term.setBackgroundColor(colors.black)
- shell.run("clear")
- error()
- end
- while true do
- e,par1,par2,par3=os.pullEvent()
- if e=="key" then
- print(par1)
- if par1==nil then
- print("NIL")
- else if par1==205 or par1==208 then
- if selected==3 then
- selected=1
- else
- selected=selected+1
- end
- else if par1==200 or par1==203 then
- if selected==1 then
- selected=3
- else
- selected=selected-1
- end
- else if tostring(par1)=="28" then
- if selected==1 then
- updateclient()
- else if selected==2 then
- updateserver()
- else if selected==3 then
- updateself()
- end
- end
- end
- else if par1==211 then
- exitscr()
- end
- end
- end
- end
- draw()
- sleep(0.25)
- end
- else if e=="mouse_click" then
- if par2 <= screenx-2 then
- if par2 >= screenx-5 then
- if par3 == 3 then
- exitscr()
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement