Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Digit-Code API
- function colors(mon,color)
- if mon.isColor() then
- mon.setBackgroundColor(color)
- end
- end
- function screen(mon)
- colors(mon,0x8000)
- mon.clear()
- colors(mon,0x80)
- local count = 1
- for i=2,4 do
- for j=2,6,2 do
- mon.setCursorPos(j,i)
- mon.write(tostring(count))
- count = count + 1
- end
- end
- colors(mon,0x4000)
- mon.setCursorPos(2,5)
- mon.write("C")
- colors(mon,0x20)
- mon.setCursorPos(6,5)
- mon.write("A")
- end
- function start(mon)
- local code = ""
- local hide = ""
- local valider = false
- screen(mon)
- while not valider do
- local e, side, x, y = os.pullEvent("monitor_touch")
- if x == 2 and y == 2 then
- code = code .. "1"
- hide = hide .."*"
- elseif x == 4 and y == 2 then
- code = code .. "2"
- hide = hide .."*"
- elseif x == 6 and y == 2 then
- code = code .. "3"
- hide = hide .."*"
- elseif x == 2 and y == 3 then
- code = code .. "4"
- hide = hide .."*"
- elseif x == 4 and y == 3 then
- code = code .. "5"
- hide = hide .."*"
- elseif x == 6 and y == 3 then
- code = code .. "6"
- hide = hide .."*"
- elseif x == 2 and y == 4 then
- code = code .. "7"
- hide = hide .."*"
- elseif x == 4 and y == 4 then
- code = code .. "8"
- hide = hide .."*"
- elseif x == 6 and y == 4 then
- code = code .. "9"
- hide = hide .."*"
- elseif x == 2 and y == 5 then
- code = ""
- hide = ""
- elseif x == 6 and y == 5 then
- valider = true
- end
- if string.len(code) == 6 then
- code = string.sub(code,5,6)
- hide = "*"
- end
- mon.setCursorPos(2,1)
- colors(mon,0x8000)
- mon.clearLine()
- mon.write(hide)
- end
- return code
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement