I know this is rather simple and people have done it before, but I feel that a lot of people would benefit from this.
Behold…
Spawn the E2 and a keyboard, and wire the E2 S input to the screen’s wirelink output, and the Key input to a keyboard.
Set the password up at the top of the code, and profit!
If the password is correct, it outputs 1 as Pass and clears the screen, so it’s rather versatile.
@name Password
@inputs S:wirelink Key
@outputs Pass
@persist Hold Enter:string Out:string Caps Password:string Blink
if(first()){
Password = "hello" #Set Password
#Screen Defaulting
S:writeCell(2041,1)
S:writeCell(2042,10)
S:writeString("Enter PassEnter ",8,6,40)
S:writeString("<>",14,7,50)
Enter = ""
Out = ""
}
#Blinking
timer("blink",500)
if(clk("blink")){Blink++}
if(Blink>1){Blink=0}
if($Blink&!Pass){
S:writeString("--Tibbles Password Protected--",0,0,40*!Blink)}
#Centering
Center = 14-round((Enter:length()/2))
#Making The String
if(Key==127|Key==154|Key==144|Key==158|Key==13){Hold=1}else{Hold=0} #No stupid characters
if(~Key&Key&!Hold&!Caps){
Enter+=toChar(Key)
}elseif(~Key&Key&!Hold&Caps){
Enter +=toChar(Key):upper()
}
#Caps Check
if(Key==144){Caps++}
if(Caps>1){Caps=0}
if(Caps|Key==154){
S:writeString("Capslock Active",8,9,60)
}else{S:writeString(" ":repeat(30),0,9)}
#Blurring The Password
if(~Key&Key&!Hold){Out+= "*"}
if(~Key&Key&!Pass){S:writeString("<" + Out + ">",Center,7,50)}
#Backspacing
if(Key==127){
Enter = Enter:left(Enter:length()-1)
Out = Out:left(Out:length()-1)
S:writeString(" ":repeat(30),0,7)
S:writeString("<" + Out + ">",Center,7,50)
S:writeString(" ",Center-1,7)
}
#String To Password Check
if(Key==13&Enter==Password){
Pass = 1
S:writeCell(2041,1)
S:writeCell(2042,0)
}elseif(Key==13&Enter!=Password&!Pass){
S:writeString(" ":repeat(30),0,7)
Out = ""
Enter = ""
S:writeString("<>",14,7,50)
S:writeString("Invalid Password",7,10,600,50)
}