SHOW:
|
|
- or go back to the newest paste.
| 1 | - | output = {}
|
| 1 | + | function inputMask(fakeInput) |
| 2 | - | fakeInput = {"l","o","l"," ","i","t","'","s"," ","n","o","t"," ","w","o","r","k","i","n","g"}
|
| 2 | + | charCount = 0 |
| 3 | - | charCount = 0 |
| 3 | + | fakeInputTable = {}
|
| 4 | output = "" | |
| 5 | - | shell.run("clear")
|
| 5 | + | outputTable = {}
|
| 6 | - | sleep(1) |
| 6 | + | |
| 7 | - | term.setCursorBlink(true) |
| 7 | + | for i=1, string.len(fakeInput) do |
| 8 | table.insert(fakeInputTable, string.sub(fakeInput,i,i)) | |
| 9 | - | while true do |
| 9 | + | |
| 10 | - | event = nil |
| 10 | + | |
| 11 | - | key = nil |
| 11 | + | term.clear() |
| 12 | - | |
| 12 | + | term.setCursorPos(1,1) |
| 13 | - | while event ~= "char" and key ~= 14 and key ~= 28 do |
| 13 | + | sleep(1) |
| 14 | - | event, key = os.pullEvent() |
| 14 | + | |
| 15 | ||
| 16 | - | |
| 16 | + | while true do |
| 17 | - | if key ~= 14 and key ~= 28 then |
| 17 | + | event = nil |
| 18 | - | table.insert(output, key) |
| 18 | + | key = nil |
| 19 | - | charCount = charCount + 1 |
| 19 | + | |
| 20 | - | elseif key == 14 then |
| 20 | + | while event ~= "char" and key ~= 14 and key ~= 28 do |
| 21 | - | table.remove(output, #output) |
| 21 | + | event, key = os.pullEvent() |
| 22 | - | charCount = charCount - 1 |
| 22 | + | end |
| 23 | - | sleep(.2) |
| 23 | + | |
| 24 | - | else |
| 24 | + | if key ~= 14 and key ~= 28 then |
| 25 | - | break |
| 25 | + | table.insert(outputTable, key) |
| 26 | charCount = charCount + 1 | |
| 27 | - | |
| 27 | + | elseif key == 14 then |
| 28 | - | shell.run("clear")
|
| 28 | + | table.remove(outputTable, #outputTable) |
| 29 | - | for i=1,#output do if fakeInput[i] ~= nil then term.write(fakeInput[i]) end end |
| 29 | + | charCount = charCount - 1 |
| 30 | - | |
| 30 | + | sleep(.2) |
| 31 | else | |
| 32 | - | end |
| 32 | + | break |
| 33 | end | |
| 34 | - | term.setCursorPos(1,3) |
| 34 | + | |
| 35 | - | term.setTextColor(colors.green) |
| 35 | + | term.clear() |
| 36 | - | for j=1,#output do term.write(output[j]) end |
| 36 | + | term.setCursorPos(1,1) |
| 37 | - | term.setCursorPos(1,4) |
| 37 | + | for i=1,#outputTable do if fakeInputTable[i] ~= nil then term.write(fakeInputTable[i]) end end |
| 38 | term.setCursorBlink(true) | |
| 39 | end | |
| 40 | ||
| 41 | term.setCursorPos(1,3) | |
| 42 | ||
| 43 | for i=1,#outputTable do | |
| 44 | output = output .. outputTable[i] | |
| 45 | end | |
| 46 | ||
| 47 | return output | |
| 48 | end |