Submit Your Own Code

PSP Lua CodeBase : Name Entry

Description:
this is a revamped edition of one of the other password codes here i have made it so you must enter your parental control password and then you just change the bottom bit of the code so if the passord is correct it does this if its incorrect it does this (see comments at bottom of code) also i extracted this from my app and i had to change a few things so that it would work without the other files in my app so you might have to change a few thing but im pretty sure i got it all

-- EVILMANA.COM PSP LUA CODEBASE
-- www.evilmana.com/tutorials/codebase
-- USER NAME ENTRY
-- BY: CHARLIE (Evilmana Site Owner)

-- CONTROLS
-- Cross (X) inputs a character
-- Square deletes a character
-- Triangle alternates uppercase and lowercase letters
-- D-pad selects characters
-- Blank space is located to the right of the letter 'z'

white = Color.new(255,255,255)
red = Color.new(255,0,0)

characters = { "a", "b", "c", "d", "e", "f", "g", 
"h", "i", "j", "k", "l", "m",
 "n", "o", "p", "q", "r", "s", "t", "u", "v", "w",
 "x", "y", "z", " " }

selector = Image.createEmpty(10,10)
selector:clear(red)

charX = 100
charY= 100

currentLetter = 1

currentX = 107
currentY = 98

uppercase = true

name = ""

oldpad = Controls.read()


addX = 0
addY = -10
addRow = -9

-- FUNCTION TO DRAW LETTERS
function drawLetters()
for a = 1, 3 do
addX = 0
addY = addY + 10
addRow = addRow + 9
for b = 1, 9 do
addX = addX + 10
if uppercase == false then
screen:print(charX + addX,charY + addY, 
characters[b + addRow],white)
else
screen:print(charX + addX,charY + addY, 
string.upper(characters[b + addRow]),white)
end
end
end
addX = 0
addY = -10
addRow = -9
end
-- END FUNCTION

-- LOOP
while true do
pad = Controls.read()

screen:clear()
if tostring(pad) == "Controls (0)" then
screen:print(10,30,tostring(Controls.read()),white)
else
screen:print(10,30,"yay",white)
end

screen:print(10,10,"Enter Name: "..name,white)
screen:blit(currentX,currentY, selector)

drawLetters()

-- TYPE LETTERS
if pad:cross() and oldpad:cross() ~= pad:cross() then
if uppercase == false then
name = name .. characters[currentLetter]
else
name = name .. string.upper(characters[currentLetter])
end
end

-- DELETE LETTER
if pad:square() and oldpad:square() ~= pad:square() then
name = string.sub(name, 1, string.len(name) - 1)
end

-- UPPER OR LOWER
if pad:triangle() and oldpad:triangle() ~= pad:triangle() then
if uppercase == false then
uppercase = true
else
uppercase = false
end
end

-- MOVE SELECTOR RIGHT
if pad:right() and currentLetter ~= 9 and 
currentLetter ~= 18 and currentLetter ~= 27
 and oldpad:right() ~= pad:right() then
currentLetter = currentLetter + 1
currentX = currentX + 10
elseif pad:right() and oldpad:right() ~= pad:right() then
if currentLetter == 9 or currentLetter == 18
 or currentLetter == 27 then
currentLetter = currentLetter - 8
currentX = 107
end
end
-- MOVE SELECTOR LEFT
if pad:left() and currentLetter ~= 1 and 
currentLetter ~= 10 and currentLetter ~= 19
 and oldpad:left() ~= pad:left() then
currentLetter = currentLetter - 1
currentX = currentX - 10
elseif pad:left() and oldpad:left() ~= pad:left() then
if currentLetter == 1 or currentLetter == 10 or
 currentLetter == 19 then
currentX = 107 + 80
currentLetter = currentLetter + 8
end
end

-- MOVE SELECTOR DOWN
if pad:down() and currentLetter < 19 and
 oldpad:down() ~= pad:down() then
currentLetter = currentLetter + 9
currentY = currentY + 10
elseif pad:down() and currentLetter > 18 and
 oldpad:down() ~= pad:down() then
currentY = 98
currentLetter = currentLetter - 18
end

-- MOVE SELECTOR UP
if pad:up() and currentLetter > 9 and 
oldpad:up() ~= pad:up() then
currentLetter = currentLetter - 9
currentY = currentY - 10
elseif pad:up() and currentLetter < 18 and 
oldpad:up() ~= pad:up() then
currentY = 118
currentLetter = currentLetter + 18
end

screen.flip()
screen.waitVblankStart()
oldpad = pad
end

Back to CodeBase
 

Please welcome jramada, our newest member.

Who's Online: 3 Guests, 1 User
PL3X

Total Members: 555
Total Posts: 13058
Total Topics: 1480
Total Categories: 8
Total Boards: 35

Recent Posts:

Re: Lua Loader? by Buddy4point0
Re: Lua Loader? by osgeld
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl
Lua Loader? by acer5050
Re: PGELua Help - need term for a special rotation fix (mathematical issue) by bumuckl


 
Copyright © 2006-2007 www.EvilMana.com All rights reserved.
EvilMana Logo by emcp and Charlie