Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --credit to CraniumKid22 for limitRead
- function limitRead(limX, rChar)
- term.setCursorBlink(true)
- local origX, origY = term.getCursorPos()
- local returnString = ""
- while true do
- local xPos, yPos = term.getCursorPos()
- local event, p1, p2 = os.pullEvent()
- if event == "char" then
- returnString = returnString..p1
- if not rChar then
- if not limX then
- write(p1)
- else
- if string.len(returnString) >= limX then
- term.setCursorPos(origX, origY)
- write(string.sub(returnString, (string.len(returnString)-limX)+1))
- elseif string.len(returnString) < limX then
- write(p1)
- end
- end
- else
- if not limX then
- write(rChar)
- else
- if string.len(returnString) >= limX then
- term.setCursorPos(origX, origY)
- write(string.rep(rChar, limX))
- elseif string.len(returnString) < limX then
- write(rChar)
- end
- end
- end
- elseif event == "key" and p1 == 14 then --backspace
- returnString = string.sub(returnString, 1, (string.len(returnString))-1)
- term.setCursorPos(xPos-1,yPos)
- write(" ")
- term.setCursorPos(origX, origY)
- if string.len(returnString) >= limX then
- if not rChar then
- write(string.sub(returnString, (string.len(returnString)-limX)+1))
- else
- write(string.rep(rChar,limX))
- end
- else
- if not rChar then
- write(returnString)
- else
- write(string.rep(rChar, string.len(returnString)))
- end
- end
- elseif event == "key" and p1 == 28 then --enter
- break
- end
- end
- term.setCursorBlink(false)
- return returnString
- end
- --paste the screen for user to enter password
- function pastePasswordScreen()
- shell.run("clear")
- term.setTextColor(colors.red)
- print("+---+-----------------------+")
- print("| | Private Archives |")
- print("| +-----------------------+")
- print("| | Password: |")
- print("| | > |")
- print("+---+-----------------------+")
- term.setTextColor(colors.lime)
- term.setCursorPos(2,2)
- print("C T")
- term.setCursorPos(2,3)
- print("u e")
- term.setCursorPos(2,4)
- print("b c")
- term.setCursorPos(2,5)
- print("e h")
- --temp
- wait(10)
- end
- --start
- pastePasswordScreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement