Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function inputCode(x, y, mask)
- local num = ui.new() -- Creates
- local numpad = num:addButton('numpad', 0, 1, {' 987 ',' 654',' 321',' X0V'})
- local screen = num:addLabel('screen', 0,0, ' ')
- numpad:setAction('input')
- num:setCommonAttribute({name = ''},{cont = 'num_origin'})
- numpad:setColors(colors.lime, colors.lightBlue)
- screen:setColors(colors.white, colors.blue)
- num:addPoint('num_origin', x, y)
- local length = screen.text:len()
- local current = ''
- while true do
- num:draw()
- local _, m, x, y = os.pullEvent('mouse_click')
- click = num:mouse({x,y})
- if click then
- if click[1][1] == 'input' then
- local text = num.ui[click[1][2]].text
- local xx, yy = unpack(click[1][3])
- local single = string.sub(text[yy],xx,xx)
- if single ~= 'V' and single ~= 'X' and single ~= ' ' and current:len() ~= length then
- current = current..single
- if not(mask) then
- screen.text = current..string.rep(' ', length - current:len())
- else
- screen.text = string.rep(mask:sub(1,1),current:len())..string.rep(' ', length - current:len())
- end
- elseif single == 'V' then
- return current
- elseif single == 'X' then
- return nil
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement