Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --(C) Corona 2013
- --DO NOT STEAL THIS CODE!!!
- os.loadAPI(shell.dir().."/screen")
- local version = 1.2
- local maxx,maxy = term.getSize()
- local cb = false
- local cp=1
- local tmpstr = ""
- local password = "Corona"
- local msg = "Please Log In:"
- local loginButton = {x1=(maxx/2-15),x2=(maxx/2+15),y1=(maxy/2+6),y2=(maxy/2+10),color=colors.lightBlue,text="LOGIN"}
- local loginArea = {x1=(maxx/2-20),x2=(maxx/2+20),y1=(maxy/2),y2=(maxy/2+3),color=colors.lightBlue,text={}}
- local wrongPassword = {x1=(maxx/2-20),x2=(maxx/2+20),y1=(maxy/2-5),y2=(maxy/2+5),text="WRONG PASSWORD",color=colors.red}
- function cls()
- term.clear()
- term.setCursorPos(1,1)
- end
- function empty(tab)
- for i=1,#tab do
- tab[i]=nil
- end
- end
- function login()
- term.setCursorPos(1,1)
- for i=1,#loginArea["text"] do
- tmpstr = tmpstr..(loginArea["text"][i])
- end
- if tmpstr == password then
- cls()
- print("Correct Password! Login Mask Version "..version)
- error()
- end
- term.setCursorBlink(false)
- screen.drawButton(wrongPassword)
- sleep(2)
- tmpstr=""
- cp=1
- empty(loginArea["text"])
- cls()
- term.setCursorBlink(true)
- end
- cls()
- while true do
- term.setCursorPos(maxx/2-#msg/2,maxy/2-5)
- term.write(msg)
- screen.drawBox(loginArea)
- screen.drawButton(loginButton)
- screen.getFocus(loginArea)
- local tx,ty = term.getCursorPos()
- term.setCursorPos(tx+cp-1,ty)
- local evn,mixed,x,y = os.pullEvent()
- if evn == "mouse_click" then
- if screen.pressed(loginButton,x,y) then
- login()
- end
- if screen.pressed(loginArea,x,y) then
- term.setCursorBlink(true)
- cb = true
- else
- term.setCursorBlink(false)
- cb = false
- end
- end
- if (evn == "char") and (cb) and (cp<(loginArea["x2"]-loginArea["x1"]-1)) then
- loginArea["text"][cp] = mixed
- write("*")
- cp = cp+1
- end
- if (evn == "key") and (cb) then
- if (mixed == 14) and (cp>1) then
- cp = cp-1
- local xt,yt = term.getCursorPos()
- term.setCursorPos(xt-1,yt)
- write(" ")
- loginArea["text"][cp] = nil
- elseif mixed == 28 then
- login()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement