Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- keys = {"esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "back", "tab", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", "enter", "ctrl", "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", nil, "shift", nil, "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", nil, "*", nil, " "}
- string = ""
- function limitread(num, hide)
- string = ""
- for i=0, num, 1 do
- event, key = os.pullEvent("key")
- if keys[key] ~= nil and num ~= nil then
- if keys[key] == "enter" then
- return string
- elseif keys[key] == "back" then
- --oldString = string
- -- string = string.sub(string, #string-1)
- -- m, n = term.getCursorPos()
- -- x, y = term.getCursorPos()
- -- x = x - #string
- -- for f=0, #oldString, 1 do
- -- write(" ")
- -- end
- -- for b=0, #string, 1 do
- -- if hide ~= nil then
- -- write(string)
- -- else
- -- for v=0, #string, 1 do
- -- write(hide)
- -- end
- -- end
- --end
- -- ]]
- else
- if hide == nil then
- write(keys[key])
- else
- write(hide)
- end
- string = string..keys[key]
- end
- end
- end
- return string
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement