Jump to content




Masked Input Api


  • You cannot reply to this topic
1 reply to this topic

#1 luza

  • New Members
  • 43 posts
  • LocationGermany

Posted 22 February 2012 - 04:12 PM

DERP DERP. I JUT REALISED read("*") DOES THE SAME...





function maskedInput(pReplace)
local replace = pReplace or "*"
local x,y = term.getCursorPos()
local input = {}
term.setCursorBlink(true)

while true do
    local event, p1 = os.pullEvent()
    if event == "char" then
	    input[#input+1]=p1
	    write(replace)
    elseif event == "key" then
	    if p1 == 28 then --enter
		    break
	    elseif p1 == 14 then --backspace
		    table.remove(input)
		    term.setCursorPos(x+#input, y)
		    write(" ")
		    term.setCursorPos(x+#input, y)
	    end
    end
end
 print("")
term.setCursorBlink(false)
return table.concat(input)
end





#2 wilcomega

  • Members
  • 466 posts
  • LocationHolland

Posted 23 February 2012 - 07:29 PM

^_^/>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users