Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --cargamos images
- seleccion = image.load("imgXkey/cuadrado.png")
- --el tiempo para que "parpadee"
- tiempo = timer.new()
- tiempo:start()
- --tablas con los teclados
- minus = {
- {"q","w","e","r","t","y","u","i","o","p"},
- {"a","s","d","f","g","h","j","k","l","ñ"},
- {"mayus","z","x","c","v","b","n","m","esp","OK"},
- img = image.load("imgXkey/tecladominus.png")
- }
- mayus= {
- {"Q","W","E","R","T","Y","U","I","O","P"},
- {"A","S","D","F","G","H","J","K","L","Ñ"},
- {"num","Z","X","C","V","B","N","M","esp","OK"},
- img = image.load("imgXkey/tecladomayus.png")
- }
- num= {
- {"0","1","2","3","4","5","6","7","8","9"},
- {".",",","-","_","(",")","[","]","!","?"},
- {"minus","á","é","í","ó","ú","`","´","esp","OK"},
- img = image.load("imgXkey/tecladosimb.png")
- }
- function xkeyboard(Xteclado,Yteclado,Xtexto,Ytexto,texto,comentario)
- --hacemos captura
- local tmp = screen.toimage()
- --definimos la posicion del "seleccionador " del teclado
- local x=1
- local y=1
- --empezamos con el teclado minusculas
- local tecladoactual=minus
- --para que "texto,comentario" sea opcional
- if not texto then texto = "" end
- if not comentario then comentario = "" end
- while true do
- --leemos controles y bliteamos la captura previamente hecha antes de entrar en el bucle
- controls.read()
- tmp:blit(0,0)
- --si pulsanmos un boton que se mueva el "seleccionador"
- if controls.press("right") then x=x+1 end
- if controls.press("left") then x=x-1 end
- if controls.press("up") then y=y-1 end
- if controls.press("down") then y=y+1 end
- --limites para el seleccionador
- if y>=4 then y=1 end
- if y<=0 then y=3 end
- if x>=11 then x=1 end
- if x<=0 then x=10 end
- --si pulsamos cruz que escriba que haga lo que tenga que hacer
- if controls.press("cross") then
- if tecladoactual[y][x] != "mayus" and tecladoactual[y][x] != "minus" and tecladoactual[y][x] != "num" and
- tecladoactual[y][x] != "esp" and tecladoactual[y][x] != "OK" then texto = texto..tecladoactual[y][x] end
- if tecladoactual[y][x] == "mayus" then tecladoactual = num
- elseif tecladoactual[y][x] == "num" then tecladoactual = minus
- elseif tecladoactual[y][x] == "minus" then tecladoactual = mayus
- elseif tecladoactual[y][x] == "OK" then break
- elseif tecladoactual[y][x] == "esp" then texto = texto.." " end
- end
- --complementa a la parida monumental
- if controls.cross() then screen.print(Xtexto+screen.textwidth(comentario..texto,0.7),Ytexto,"|") end
- --para poder eliminar una letra
- if controls.press("square") then texto = string.sub(texto,1,#texto-1) end
- --poner un espacio
- if controls.press("triangle") then texto = texto.." " end
- --eliminar todo
- if controls.press("circle") then texto = "" end
- --cambiar de teclado pulsando select
- if controls.press("select") then
- if tecladoactual == mayus then tecladoactual = num
- elseif tecladoactual == num then tecladoactual = minus
- elseif tecladoactual == minus then tecladoactual = mayus end
- end
- --mover el teclado con el joystick
- if math.abs(controls.analogx())>15 then Xteclado = Xteclado + controls.analogx()/10 end
- if math.abs(controls.analogy())>15 then Yteclado = Yteclado + controls.analogy()/10 end
- --imprimir y blitear el teclado, el "seleccionador" y el texto k tamos escribiendo
- tecladoactual.img:blit(Xteclado,Yteclado)
- seleccion:blit(Xteclado+(21*x)-10,Yteclado+(21*y)-(9+y))
- screen.print(Xtexto,Ytexto,comentario..texto)
- --bye bye teclado
- if controls.press("start") then
- tmp:free()
- break
- end
- screen.print(5,5,tiempo:time())------------------------------------------------------------
- --parida monumental(hace el efecto de barra parpadeante)
- if not controls.cross() and tiempo:time() >= 0 and tiempo:time() < 500 then
- screen.print(Xtexto+screen.textwidth(comentario..texto,0.7),Ytexto,"|")
- elseif tiempo:time() >= 1000 then tiempo:reset()
- end
- --flipeamos un poko
- screen.flip()
- if controls.press("l") then xerpi() end ----------------------------------------------------
- end
- return texto
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement