nvm guys i fugured it out
Printable View
nvm guys i fugured it out
ok how can i make it were this image gos back and fourth?http://img183.imageshack.us/img183/7549/flowerez7.png
I want it inserted in this code were the code still works but I cant figure out were to put it
Code:grass = Image.load("grass.png")
player = Image.load("player.png")
flower = Image.load("flower.png")
start = Image. load("start.png")
white = Color.new(255,255,255)
counter = Timer.new()
screenwidth = 480 - player:width()
screenheight = 272 - player:width()
Player = { }
Player[1] = { x = 200, y = 50 }
while true do
pad = Controls.read()
screen:clear()
counter:start()
screen:clear()
currentTime = counter:time()
if currentTime < 1000 then
screen:print(100,100,"Loading",white)
end
if currentTime > 1000 then
screen:print(100,100,"Loading",white)
end
if currentTime > 2000 then
screen:print(100,100,"Loading.",white)
end
if currentTime > 3000 then
screen:print(100,100,"Loading..",white)
end
if currentTime > 4000 then
screen:print(100,100,"Loading...",white)
end
if currentTime > 5000 then
screen:print(100,100,"Loading....",white)
end
if currentTime > 6000 then
screen:print(100,100,"Loading....Almost done",white)
end
if currentTime > 7000 then
screen:print(100,100,"Loading....Almost done.",white)
end
if currentTime > 8000 then
screen:print(100,100,"Loading....Almost done..",white)
end
if currentTime > 9000 then
screen:print(100,100,"Loading....Almost done...",white)
end
if currentTime > 10000 then
screen:print(100,100,"Loading....Almost done...f",white)
end
if currentTime > 10100 then
screen:print(100,100,"Loading....Almost done...fi",white)
end
if currentTime > 10200 then
screen:print(100,100,"Loading....Almost done...fin",white)
end
if currentTime > 10300 then
screen:print(100,100,"Loading....Almost done...fina",white)
end
if currentTime > 10400 then
screen:print(100,100,"Loading....Almost done...final",white)
end
if currentTime > 10500 then
screen:print(100,100,"Loading....Almost done...finaly",white)
end
if currentTime > 10600 then
screen:print(100,100,"Loading....Almost done...finaly d",white)
end
if currentTime > 10700 then
screen:print(100,100,"Loading....Almost done...finaly do",white)
end
if currentTime > 10800 then
screen:print(100,100,"Loading....Almost done...finaly don",white)
end
if currentTime > 10900 then
screen:print(100,100,"Loading....Almost done...finaly done",white)
end
if currentTime > 12000 then
screen:print(150,110,"Get to the finish line",white)
end
if currentTime > 12100 then
screen:print(150,120,"Lvl. 1",white)
end
if currentTime > 20000 then
counter:stop()
end
--Were grass goes(top)
screen:blit(0,0,grass)
screen:blit(32,0,grass)
screen:blit(64,0,grass)
screen:blit(96,0,grass)
screen:blit(128,0,grass)
screen:blit(160,0,grass)
screen:blit(192,0,grass)
screen:blit(224,0,grass)
screen:blit(256,0,grass)
screen:blit(288,0,grass)
screen:blit(320,0,grass)
screen:blit(352,0,grass)
screen:blit(384,0,grass)
screen:blit(416,0,grass)
screen:blit(448,0,grass)
--More grass(right under top)
screen:blit(0,32,grass)
screen:blit(32,32,grass)
screen:blit(64,32,grass)
screen:blit(96,32,grass)
screen:blit(128,32,grass)
screen:blit(160,32,grass)
screen:blit(192,32,grass)
screen:blit(224,32,grass)
screen:blit(256,32,grass)
screen:blit(288,32,grass)
screen:blit(320,32,grass)
screen:blit(352,32,grass)
screen:blit(384,32,grass)
screen:blit(416,32,grass)
screen:blit(448,32,grass)
--More grass(third row)
screen:blit(0,64,grass)
screen:blit(32,64,grass)
screen:blit(64,64,grass)
screen:blit(96,64,grass)
screen:blit(128,64,grass)
screen:blit(160,64,grass)
screen:blit(192,64,grass)
screen:blit(224,64,grass)
screen:blit(256,64,grass)
screen:blit(288,64,grass)
screen:blit(320,64,grass)
screen:blit(352,64,grass)
screen:blit(384,64,grass)
screen:blit(416,64,grass)
screen:blit(448,64,grass)
--forth row
screen:blit(0,96,grass)
screen:blit(32,96,grass)
screen:blit(64,96,grass)
screen:blit(386,96,grass)
screen:blit(416,96,grass)
screen:blit(448,96,grass)
--fith row
screen:blit(0,128,grass)
screen:blit(32,128,grass)
screen:blit(64,128,grass)
screen:blit(96,128,grass)
screen:blit(128,128,grass)
screen:blit(160,128,grass)
screen:blit(192,128,grass)
screen:blit(224,128,grass)
screen:blit(256,128,grass)
screen:blit(288,128,grass)
screen:blit(320,128,grass)
screen:blit(352,128,grass)
screen:blit(384,128,grass)
screen:blit(416,128,grass)
screen:blit(448,128,grass)
--Sixth row
screen:blit(0,160,grass)
screen:blit(32,160,grass)
screen:blit(64,160,grass)
screen:blit(96,160,grass)
screen:blit(128,160,grass)
screen:blit(160,160,grass)
screen:blit(192,160,grass)
screen:blit(224,160,grass)
screen:blit(256,160,grass)
screen:blit(288,160,grass)
screen:blit(320,160,grass)
screen:blit(352,160,grass)
screen:blit(384,160,grass)
screen:blit(416,160,grass)
screen:blit(448,160,grass)
--Seventh Row
screen:blit(0,192,grass)
screen:blit(32,192,grass)
screen:blit(64,192,grass)
screen:blit(96,192,grass)
screen:blit(128,192,grass)
screen:blit(160,192,grass)
screen:blit(192,192,grass)
screen:blit(224,192,grass)
screen:blit(256,192,grass)
screen:blit(288,192,grass)
screen:blit(320,192,grass)
screen:blit(352,192,grass)
screen:blit(384,192,grass)
screen:blit(416,192,grass)
screen:blit(448,192,grass)
--eighth row
screen:blit(0,224,grass)
screen:blit(32,224,grass)
screen:blit(64,224,grass)
screen:blit(96,224,grass)
screen:blit(128,224,grass)
screen:blit(160,224,grass)
screen:blit(192,224,grass)
screen:blit(224,224,grass)
screen:blit(256,224,grass)
screen:blit(288,224,grass)
screen:blit(320,224,grass)
screen:blit(352,224,grass)
screen:blit(384,224,grass)
screen:blit(416,224,grass)
screen:blit(448,224,grass)
--ninth Row
screen:blit(0,256,grass)
screen:blit(32,256,grass)
screen:blit(64,256,grass)
screen:blit(96,256,grass)
screen:blit(128,256,grass)
screen:blit(160,256,grass)
screen:blit(192,256,grass)
screen:blit(224,256,grass)
screen:blit(256,256,grass)
screen:blit(288,256,grass)
screen:blit(320,256,grass)
screen:blit(352,256,grass)
screen:blit(384,256,grass)
screen:blit(416,256,grass)
screen:blit(448,256,grass)
--Start
screen:blit(195,45,start)
--Flower paths(around start image)
screen:blit(230,25,flower)
screen:blit(220,25,flower)
screen:blit(210,25,flower)
screen:blit(200,25,flower)
screen:blit(190,25,flower)
screen:blit(180,25,flower)
screen:blit(170,25,flower)
screen:blit(170,30,flower)
screen:blit(170,42,flower)
screen:blit(170,50,flower)
screen:blit(170,60,flower)
screen:blit(170,70,flower)
screen:blit(180,70,flower)
screen:blit(190,70,flower)
screen:blit(200,70,flower)
screen:blit(210,70,flower)
screen:blit(220,70,flower)
screen:blit(230,70,flower)
screen:blit(300,220,flower)
screen:blit(Player[1].x,Player[1].y,player)
if pad:left() and Player[1].x > 0 then
Player[1].x = Player[1].x - 2
end
if pad:right() and Player[1].x < screenwidth then
Player[1].x = Player[1].x + 2
end
if pad:up() and Player[1].y > 0 then
Player[1].y = Player[1].y - 2
end
if pad:down() and Player[1].y < screenheight then
Player[1].y = Player[1].y + 2
end
screen.waitVblankStart()
screen.flip()
end
I don't know what you're asking for. If it's AI or animation, specify which and I (or someone else) can help, but for now your code is way too inefficient.
Read this before you continue:
http://evilmana.com/tutorials/lua_tutorial_07.php
What you're looking for there is:
If you don't understand, there's an explanation in the tutorial.Code:for a = 0, 14 do
for b = 0,8 do
screen:blit(32 * a, 32 * b, grass)
end
end
Also, 'finaly' is spelled with two Ls.
Yes i know that code, but i dont use it because it blits over the text.Zitat:
Zitat von Aphonia
and its animation...i have a code right their i just dont know were to put it
-= Double Post =-
and i will fix the finally lol
The undead, you have A LOT of unneeded code. Read this tutorial. It will help you slim all image code down to 5 or 6 lines.
Zitat:
Zitat von the undead
then all you do, is FISRT blit all the grass stuff, THEN print your text. itll show.
I already tried that, but I will try againZitat:
Zitat von Grimfate126
Offtopic :
I am not coding or anything, I'm just trying to find some info about a lua game. So excuse my noob questions. Its been a couple of days now but i didn't get any ideas.
So if some lua coders have some spare time please have a look at the thread i started in psp general and give me a more professional opinion about it.
It would be highly appreciated! :D
The thread with pics and the game is here
Ok im trying to put this code in
But it says error:a.lua:3:'=' expected near fontCode:Font Font.load(btseps2.ttf)
so i put this in instead
but now I get this error:a.lua:3: attempt to index global 'font' a nil valueCode:Font = Font.load(btseps2.ttf)
What is wrong?
is you path to the font correct? and are you declaring it before you use it?
yes the path to the file is right(its in the same folder)Zitat:
Zitat von Bronx
and what do you mean declaring it?
right now im just loading it
Code:ANewFont = Font.load("btseps2.ttf")
Ok thanks, ill try thatZitat:
Zitat von head_54us
-= Double Post =-
I still get the nil value error
Are you using the latest LuaPlayer?
yes I amZitat:
Zitat von head_54us
Show the line of code you are using now to check if you got the syntax correct.
Im starting a program, but i need to test this fontZitat:
Zitat von head_54us
Code:red = Color.new(255, 0, 0)
ANewFont = Font.load("btseps2.ttf")
screen:print(200, 100, "Font test", ANewFont)
screen.flip()
while true do
screen.waitVblankStart()
end
What Line do you get the error on?
sidenote: You are not meant to use screen:print with fonts, ou would want screen:fontprint(ANewFont , 200, 100, "Font test")
ahh i see, ididnt know that...um line 3...let me try thatZitat:
Zitat von head_54us
-= Double Post =-
I used that, i still get that nil value error...line 3
-- maze of doom
menu = Image.load("menu.jpeg")
pink = Color.new(255, 0 , 153)
blue = Color.new(0 , 153, 255)
orange = Color.new(255, 102, 0)
gray = Color.new(153, 153, 153)
black = Color.new(0 , 0 , 0)
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:blit(0,0,menu)
screen.print (10, 100, "Press X to Start" green)
screen.print (20, 150, "Maze of Doom created by: GuitarGod1124 also known as GuitarGod1134" orange)
screen:clear()
if pad:cross()then
screen.print (10, 100, "Coming Soon...." orange)
end
screen.flip()
screen.waitVblankStart()
oldpad = pad
end
okay everytime I try to start this it gives me an error saying
Error: SCRIPT.LUA:13: ')' expected near 'green'
Press start to restart
can someone help? At first i thought i didnt flip it on to the on screen buffer but i did. didnt i?
Should work, there were a few errors in there, like not putting a comma after some of your arguments, and not defining the color green, but I fixed it up.Code:menu = Image.load("menu.jpeg")
pink = Color.new(255, 0 , 153)
blue = Color.new(0 , 153, 255)
orange = Color.new(255, 102, 0)
gray = Color.new(153, 153, 153)
black = Color.new(0 , 0 , 0)
green = Color.new(0,255,0)
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:blit(0,0,menu)
screen.print (10, 100, "Press X to Start", green)
screen.print (20, 150, "Maze of Doom created by: GuitarGod1124 also known as GuitarGod1134", orange)
screen:clear()
if pad:cross()then
screen.print (10, 100, "Coming Soon....", orange)
end
screen.flip()
screen.waitVblankStart()
oldpad = pad
end
Same as Macca's, except for the screen:clear() needs to be before you screen:blit or screen:print else you'll clear the screen as soon as they are put on.Code:menu = Image.load("menu.jpeg")
pink = Color.new(255, 0 , 153)
blue = Color.new(0 , 153, 255)
orange = Color.new(255, 102, 0)
gray = Color.new(153, 153, 153)
black = Color.new(0 , 0 , 0)
green = Color.new(0,255,0)
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:clear()
screen:blit(0,0,menu)
screen:print (10, 100, "Press X to Start", green)
screen:print (20, 150, "Maze of Doom created by: GuitarGod1124 also known as GuitarGod1134", orange)
if pad:cross()then
screen:print (10, 100, "Coming Soon....", orange)
end
screen.flip()
screen.waitVblankStart()
oldpad = pad
end
And Im fairly sure isnotCode:screen:blit and screen:print
.Code:screen.print and screen.blit
Correct me if im wrong
okay thanks guys
-= Double Post =-
O WOW i had no idea i didnt define green. missed that lol.
im getting a image loading error. where do i put my menu.jpeg?
in the same folder as the index.lua. If you put in in another folder then you would have to change
Code:menu = Image.load("menu.jpeg")
to
menu = Image.load("foldername/menu.jpeg")
okay thanks
There is a link in the stickys
i am having a problem loading this for some reason..
Code:bg = Image.load("background.png")
red = Color.new(255,0,0)
green = Color.new(0,255,0)
white = Color.new(255,255,255)
oldpad = Controls.read()
font = Font.load("visitor.ttf")
font:setPixelSizes(0, 32)
RN0 = math.random(1,3)
RN1 = math.random(1,3)
RN2 = math.random(1,3)
while true do
pad = Controls.read()
if pad:square() then
RN0 = math.random(1,3)
end
if pad:square() then
RN1 = math.random(1,3)
end
if pad:square() then
RN2 = math.random(1,3)
end
screen:fontPrint(font, 165,150, RN0, red)
screen:fontPrint(font, 195,150, RN1, red)
screen:fontPrint(font, 220,150, RN2, red)
elseif (math.random(1,3) > 1) then
screen:blit(0,0, bg)
screen:fontPrint(font, 10,150, "YOU WON THE JACKPOT!!", green)
end
elseif (math.random(1,3) > 2) then
screen:blit(0,0, bg)
screen:fontPrint(font, 10,150, "YOU WON THE JACKPOT!!", green)
end
elseif (math.random(1,3) > 3) then
screen:blit(0,0, bg)
screen:fontPrint(font, 10,150, "YOU WON THE JACKPOT!!", green)
end
screen.flip()
screen.waitVblankStart()
oldpad = pad
end
well you have no screen:clear()
you cant just use elseif. You have to use it like this:
if bla==bla2 then
something
elseif bla~=bla2 then
somethingelse
end
also
can be:Code:if pad:square() then
RN0 = math.random(1,3)
end
if pad:square() then
RN1 = math.random(1,3)
end
if pad:square() then
RN2 = math.random(1,3)
end
Another thing, put this in the main loop once and in the beginning:Code:if pad:square() then
RN0 = math.random(1,3)
RN1 = math.random(1,3)
RN2 = math.random(1,3)
end
And yeah, you should have "screen:clear()" in your main loop. In the beginning and before the "screen:blit(0,0, bg)".Code:screen:blit(0,0, bg)
idk it says you won the jackpot automatically when i start the game.. heres the code,
-= Double Post =-Code:System.usbDiskModeActivate()
red = Color.new(255,0,0)
green = Color.new(0,255,0)
white = Color.new(255,255,255)
oldpad = Controls.read()
font = Font.load("visitor.ttf")
font:setPixelSizes(0, 32)
screen:clear()
math.randomseed(os.time())
RN0 = math.random(1,3)
RN1 = math.random(1,3)
RN2 = math.random(1,3)
RN9 = complete
bg = Image.load("background.png")
while true do
pad = Controls.read()
if pad:square() then
RN0 = math.random(1,3)
RN1 = math.random(1,3)
RN2 = math.random(1,3)
end
screen:fontPrint(font, 165,150, RN0, red)
screen:fontPrint(font, 195,150, RN1, red)
screen:fontPrint(font, 220,150, RN2, red)
if RN0 == 1 and RN9 == complete then
RN9 = one
end
if RN1 == 1 and RN9 == one then
RN9 = two
end
if RN2 == 1 and RN9 == two then
RN9 = three
end
if RN9 == three then
RN9 = complete
screen:clear()
screen:blit(0,0, bg)
screen:fontPrint(font, 10,150, "YOU WON THE JACKPOT!!", green)
end
screen.flip()
screen.waitVblankStart()
end
bump!!!!!!!!!!!!!!!!!!!!! !!!!!
well...in the beginning you already made "RN9" equal to "complete".
plus, it seems all this is pointless...:
Code:if RN0 == 1 and RN9 == complete then
RN9 = one
end
if RN1 == 1 and RN9 == one then
RN9 = two
end
if RN2 == 1 and RN9 == two then
RN9 = three
end
complete, one, two and three are all nil variables rather then string literals (which is what I assume you are trying to use).
i have 2 questions:
1st. how do i save text which i typed in MagicianFBs keyboard???
2nd:Code:keyyellow = Color.new(255, 255, 0)
keywhite = Color.new(255, 255, 255)
keyblue = Color.new(0, 0, 255)
keyblack = Color.new(0, 0, 0)
keygreen = Color.new(0, 127, 0)
keyorange = Color.new(255, 100, 0)
keygray = Color.new(127, 127, 127)
text = ""
function drawRect(where, x, y, width, height, color)
where:drawLine(x, y, x+width, y, color)
where:drawLine(x+width, y, x+width, y+height, color)
where:drawLine(x+width, y+height, x, y+height, color)
where:drawLine(x, y+height, x, y, color)
end
keyscreen = Image.createEmpty(480, 272)
keyscreen:clear(keyyellow)
textdisp = Image.createEmpty(300, 172)
textdisp:clear(keywhite)
keyscreen:blit(150, 50, textdisp)
key0123 = Image.createEmpty(26, 26)
key4567 = Image.createEmpty(26, 26)
key89 = Image.createEmpty(26, 26)
keyabcd = Image.createEmpty(26, 26)
keyefgh = Image.createEmpty(26, 26)
keyijkl = Image.createEmpty(26, 26)
keymnop = Image.createEmpty(26, 26)
keyqrst = Image.createEmpty(26, 26)
keyuvwx = Image.createEmpty(26, 26)
keyyz = Image.createEmpty(26, 26)
keysymb = Image.createEmpty(26, 26)
keysymb2 = Image.createEmpty(26, 26)
keybrd = Image.createEmpty(80, 106)
keybrd:clear(keywhite)
keybrd:blit(1, 1, key0123)
keybrd:blit(27, 1, key4567)
keybrd:blit(53, 1, key89)
keybrd:blit(1, 27, keyabcd)
keybrd:blit(27, 27, keyefgh)
keybrd:blit(53, 27, keyijkl)
keybrd:blit(1, 53, keymnop)
keybrd:blit(27, 53, keyqrst)
keybrd:blit(53, 53, keyuvwx)
keybrd:blit(1, 79, keyyz)
keybrd:blit(27, 79, keysymb)
keybrd:blit(53, 79, keysymb2)
keybrdsel = Image.createEmpty(78, 104)
--Line 50
keyposx = 1
keyposy = 2
function keysel()
keybrdsel:clear()
keyscreen:blit(40, 91, keybrd)
drawRect(keybrdsel, ((keyposx*26)-26), ((keyposy*26)-26), 26, 26, keyblue)
keyscreen:blit(41, 92, keybrdsel)
screen:blit(0, 0, keyscreen)
screen:flip()
end
function lowercase()
case = "lower"
key0123:clear()
key4567:clear()
key89:clear()
keyabcd:clear()
keyefgh:clear()
keyijkl:clear()
keymnop:clear()
keyqrst:clear()
keyuvwx:clear()
keyyz:clear()
keysymb:clear()
keysymb2:clear()
key0123:print(10, 4, "0", keyblack)
key0123:print(16, 10, "1", keyblack)
key0123:print(4, 10, "3", keyblack)
key0123:print(10, 16, "2", keyblack)
key4567:print(10, 4, "4", keyblack)
key4567:print(16, 10, "5", keyblack)
key4567:print(10, 16, "6", keyblack)
key4567:print(4, 10, "7", keyblack)
key89:print(10, 4, "8", keyblack)
key89:print(16, 10, "9", keyblack)
keyabcd:print(10, 4, "a", keyblack)
keyabcd:print(16, 10, "b", keyblack)
keyabcd:print(10, 16, "c", keyblack)
keyabcd:print(4, 10, "d", keyblack)
keyefgh:print(10, 4, "e", keyblack)
keyefgh:print(16, 10, "f", keyblack)
keyefgh:print(10, 16, "g", keyblack)
keyefgh:print(4, 10, "h", keyblack)
-- Line 100
keyijkl:print(10, 4, "i", keyblack)
keyijkl:print(16, 10, "j", keyblack)
keyijkl:print(10, 16, "k", keyblack)
keyijkl:print(4, 10, "l", keyblack)
keymnop:print(10, 4, "m", keyblack)
keymnop:print(16, 10, "n", keyblack)
keymnop:print(10, 16, "o", keyblack)
keymnop:print(4, 10, "p", keyblack)
keyqrst:print(10, 4, "q", keyblack)
keyqrst:print(16, 10, "r", keyblack)
keyqrst:print(10, 16, "s", keyblack)
keyqrst:print(4, 10, "t", keyblack)
keyuvwx:print(10, 4, "u", keyblack)
keyuvwx:print(16, 10, "v", keyblack)
keyuvwx:print(10, 16, "w", keyblack)
keyuvwx:print(4, 10, "x", keyblack)
keyyz:print(10, 4, "y", keyblack)
keyyz:print(16, 10, "z", keyblack)
keysymb:print(10, 4, ":", keyblack)
keysymb:print(16, 10, ";", keyblack)
keysymb:print(10, 16, "-", keyblack)
keysymb:print(4, 10, "+", keyblack)
keysymb2:print(10, 4, ",", keyblack)
keysymb2:print(16, 10, "<", keyblack)
keysymb2:print(10, 16, ".", keyblack)
keysymb2:print(4, 10, ">", keyblack)
keybrd:clear(keywhite)
keybrd:blit(1, 1, key0123)
keybrd:blit(27, 1, key4567)
keybrd:blit(53, 1, key89)
keybrd:blit(1, 27, keyabcd)
keybrd:blit(27, 27, keyefgh)
keybrd:blit(53, 27, keyijkl)
keybrd:blit(1, 53, keymnop)
keybrd:blit(27, 53, keyqrst)
keybrd:blit(53, 53, keyuvwx)
keybrd:blit(1, 79, keyyz)
keybrd:blit(27, 79, keysymb)
keybrd:blit(53, 79, keysymb2)
keyscreen:blit(40, 91, keybrd)
keyscreen:blit(41, 92, keybrdsel)
screen:blit(0, 0, keyscreen)
screen:flip()
end
function uppercase()
case = "upper"
key0123:clear()
key4567:clear()
key89:clear()
keyabcd:clear()
keyefgh:clear()
keyijkl:clear()
keymnop:clear()
--Line 150
keyqrst:clear()
keyuvwx:clear()
keyyz:clear()
keysymb:clear()
keysymb2:clear()
key0123:print(10, 4, "!", keyblack)
key0123:print(16, 10, "@", keyblack)
key0123:print(4, 10, "#", keyblack)
key0123:print(10, 16, "$", keyblack)
key4567:print(10, 4, "%", keyblack)
key4567:print(16, 10, "^", keyblack)
key4567:print(10, 16, "&", keyblack)
key4567:print(4, 10, "*", keyblack)
key89:print(4, 10, "(", keyblack)
key89:print(16, 10, ")", keyblack)
keyabcd:print(10, 4, "A", keyblack)
keyabcd:print(16, 10, "B", keyblack)
keyabcd:print(10, 16, "C", keyblack)
keyabcd:print(4, 10, "D", keyblack)
keyefgh:print(10, 4, "E", keyblack)
keyefgh:print(16, 10, "F", keyblack)
keyefgh:print(10, 16, "G", keyblack)
keyefgh:print(4, 10, "H", keyblack)
keyijkl:print(10, 4, "I", keyblack)
keyijkl:print(16, 10, "J", keyblack)
keyijkl:print(10, 16, "K", keyblack)
keyijkl:print(4, 10, "L", keyblack)
keymnop:print(10, 4, "M", keyblack)
keymnop:print(16, 10, "N", keyblack)
keymnop:print(10, 16, "O", keyblack)
keymnop:print(4, 10, "P", keyblack)
keyqrst:print(10, 4, "Q", keyblack)
keyqrst:print(16, 10, "R", keyblack)
keyqrst:print(10, 16, "S", keyblack)
keyqrst:print(4, 10, "T", keyblack)
keyuvwx:print(10, 4, "U", keyblack)
keyuvwx:print(16, 10, "V", keyblack)
keyuvwx:print(10, 16, "W", keyblack)
keyuvwx:print(4, 10, "X", keyblack)
keyyz:print(10, 4, "Y", keyblack)
-- Line 200
keyyz:print(16, 10, "Z", keyblack)
keysymb:print(10, 4, "~", keyblack)
keysymb:print(16, 10, "_", keyblack)
keysymb:print(10, 16, "?", keyblack)
keysymb:print(4, 10, "/", keyblack)
keysymb2:print(10, 4, "{", keyblack)
keysymb2:print(16, 10, "]", keyblack)
keysymb2:print(10, 16, "}", keyblack)
keysymb2:print(4, 10, "[", keyblack)
keybrd:clear(keywhite)
keybrd:blit(1, 1, key0123)
keybrd:blit(27, 1, key4567)
keybrd:blit(53, 1, key89)
keybrd:blit(1, 27, keyabcd)
keybrd:blit(27, 27, keyefgh)
keybrd:blit(53, 27, keyijkl)
keybrd:blit(1, 53, keymnop)
keybrd:blit(27, 53, keyqrst)
keybrd:blit(53, 53, keyuvwx)
keybrd:blit(1, 79, keyyz)
keybrd:blit(27, 79, keysymb)
keybrd:blit(53, 79, keysymb2)
keyscreen:blit(40, 91, keybrd)
keyscreen:blit(41, 92, keybrdsel)
screen:blit(0, 0, keyscreen)
screen:flip()
end
function prints()
if case=="lower" then
if pad:triangle() then
if keyposy==1 then
if keyposx==1 then
text = text .. "0"
elseif keyposx==2 then
text = text .. "4"
elseif keyposx==3 then
text = text .. "8"
end
elseif keyposy==2 then
if keyposx==1 then
text = text .. "a"
elseif keyposx==2 then
text = text .. "e"
elseif keyposx==3 then
text = text .. "i"
end
elseif keyposy==3 then
if keyposx==1 then
text = text .. "m"
elseif keyposx==2 then
text = text .. "q"
elseif keyposx==3 then
text = text .. "u"
end
elseif keyposy==4 then
if keyposx==1 then
text = text .. "y"
elseif keyposx==2 then
text = text .. ":"
elseif keyposx==3 then
text = text .. ","
end
end
elseif pad:circle() then
if keyposy==1 then
if keyposx==1 then
text = text .. "1"
elseif keyposx==2 then
text = text .. "5"
elseif keyposx==3 then
text = text .. "9"
end
elseif keyposy==2 then
if keyposx==1 then
text = text .. "b"
elseif keyposx==2 then
text = text .. "f"
elseif keyposx==3 then
text = text .. "j"
end
elseif keyposy==3 then
if keyposx==1 then
text = text .. "n"
elseif keyposx==2 then
text = text .. "r"
elseif keyposx==3 then
text = text .. "v"
end
elseif keyposy==4 then
if keyposx==1 then
text = text .. "z"
elseif keyposx==2 then
text = text .. ";"
elseif keyposx==3 then
text = text .. "<"
end
end
elseif pad:cross() then
if keyposy==1 then
if keyposx==1 then
text = text .. "2"
elseif keyposx==2 then
text = text .. "6"
elseif keyposx==3 then
text = text .. ""
end
elseif keyposy==2 then
if keyposx==1 then
text = text .. "c"
elseif keyposx==2 then
text = text .. "g"
elseif keyposx==3 then
text = text .. "k"
end
elseif keyposy==3 then
if keyposx==1 then
text = text .. "o"
elseif keyposx==2 then
text = text .. "s"
elseif keyposx==3 then
text = text .. "w"
end
elseif keyposy==4 then
if keyposx==1 then
text = text .. ""
elseif keyposx==2 then
text = text .. "-"
elseif keyposx==3 then
text = text .. "."
end
end
elseif pad:square() then
if keyposy==1 then
if keyposx==1 then
text = text .. "3"
elseif keyposx==2 then
text = text .. "7"
elseif keyposx==3 then
text = text .. " "
end
elseif keyposy==2 then
if keyposx==1 then
text = text .. "d"
elseif keyposx==2 then
text = text .. "h"
elseif keyposx==3 then
text = text .. "l"
end
elseif keyposy==3 then
if keyposx==1 then
text = text .. "p"
elseif keyposx==2 then
text = text .. "t"
elseif keyposx==3 then
text = text .. "x"
end
elseif keyposy==4 then
if keyposx==1 then
text = text .. ""
elseif keyposx==2 then
text = text .. "+"
elseif keyposx==3 then
text = text .. ">"
end
end
elseif pad:l() then
text = string.sub(text, 1, string.len(text)-1)
elseif pad:r() then
text = text .. " "
end
elseif case=="upper" then
if pad:triangle() then
if keyposy==1 then
if keyposx==1 then
text = text .. "!"
elseif keyposx==2 then
text = text .. "%"
elseif keyposx==3 then
text = text .. ""
end
elseif keyposy==2 then
if keyposx==1 then
text = text .. "A"
elseif keyposx==2 then
text = text .. "E"
elseif keyposx==3 then
text = text .. "I"
end
elseif keyposy==3 then
if keyposx==1 then
text = text .. "M"
elseif keyposx==2 then
text = text .. "Q"
elseif keyposx==3 then
text = text .. "U"
end
elseif keyposy==4 then
if keyposx==1 then
text = text .. "Y"
elseif keyposx==2 then
text = text .. "~"
elseif keyposx==3 then
text = text .. "{"
end
end
elseif pad:circle() then
if keyposy==1 then
if keyposx==1 then
text = text .. "@"
elseif keyposx==2 then
text = text .. "^"
elseif keyposx==3 then
text = text .. ")"
end
elseif keyposy==2 then
if keyposx==1 then
text = text .. "B"
elseif keyposx==2 then
text = text .. "F"
elseif keyposx==3 then
text = text .. "J"
end
elseif keyposy==3 then
if keyposx==1 then
text = text .. "N"
elseif keyposx==2 then
text = text .. "R"
elseif keyposx==3 then
text = text .. "V"
end
elseif keyposy==4 then
if keyposx==1 then
text = text .. "Z"
elseif keyposx==2 then
text = text .. "_"
elseif keyposx==3 then
text = text .. "]"
end
end
elseif pad:cross() then
if keyposy==1 then
if keyposx==1 then
text = text .. "#"
elseif keyposx==2 then
text = text .. "&"
elseif keyposx==3 then
text = text .. ""
end
elseif keyposy==2 then
if keyposx==1 then
text = text .. "C"
elseif keyposx==2 then
text = text .. "G"
elseif keyposx==3 then
text = text .. "K"
end
elseif keyposy==3 then
if keyposx==1 then
text = text .. "O"
elseif keyposx==2 then
text = text .. "S"
elseif keyposx==3 then
text = text .. "W"
end
elseif keyposy==4 then
if keyposx==1 then
text = text .. ""
elseif keyposx==2 then
text = text .. "?"
elseif keyposx==3 then
text = text .. "}"
end
end
elseif pad:square() then
if keyposy==1 then
if keyposx==1 then
text = text .. "$"
elseif keyposx==2 then
text = text .. "*"
elseif keyposx==3 then
text = text .. "("
end
elseif keyposy==2 then
if keyposx==1 then
text = text .. "D"
elseif keyposx==2 then
text = text .. "H"
elseif keyposx==3 then
text = text .. "L"
end
elseif keyposy==3 then
if keyposx==1 then
text = text .. "P"
elseif keyposx==2 then
text = text .. "T"
elseif keyposx==3 then
text = text .. "X"
end
elseif keyposy==4 then
if keyposx==1 then
text = text .. ""
elseif keyposx==2 then
text = text .. "/"
elseif keyposx==3 then
text = text .. "["
end
end
elseif pad:l() then
text = string.sub(text, 1, string.len(text)-1)
elseif pad:r() then
text = text .. " "
end
end
maxline = math.ceil(string.len(text)/37)
printline = 1
textdisp:clear(keywhite)
while printline<=maxline do
if printline==maxline then
textend = string.len(text)
else
textend = printline*37
end
textdisp:print(3, 3+((printline-1)*8), string.sub(text, (printline-1)*37+1, textend), keyblack)
printline = printline+1
if textend==string.len(text) then
break
end
end
if string.len(text)<=37 then
curstextx = (3+(string.len(string.sub(text, (maxline-1)*37, string.len(text)))*8))
elseif string.len(text)>37 then
curstextx = (3+(string.len(string.sub(text, (maxline-1)*37, string.len(text)-1))*8))
end
textdisp:print(curstextx, 3+((maxline-1)*8), "|", keygreen)
keyscreen:blit(150, 50, textdisp)
screen:blit(0, 0, keyscreen)
screen:flip()
end
function keyboard()
text = ""
keyposx = 1
keyposy = 2
keyscreen:clear(keyyellow)
drawRect(keyscreen, 149, 49, 301, 173, keygray)
drawRect(keyscreen, 39, 90, 81, 107, keygray)
keyscreen:print(0, 17, " " .. string.rep("=", 22) .. "Text Entering" .. string.rep("=", 23), keyorange)
keyscreen:print(8, 208, " Select = Shift", keyblue)
keyscreen:print(8, 216, " Start = Enter", keyblue)
keyscreen:print(8, 224, " D-pad = Select Key", keyblue)
keyscreen:print(8, 233, " Control Pad = Print Character", keyblue)
keyscreen:print(8, 240, " L = Backspace", keyblue)
keyscreen:print(8, 248, " R = Space", keyblue)
keyscreen:blit(150, 50, textdisp)
keyscreen:blit(40, 91, keybrd)
keyscreen:blit(41, 92, keybrdsel)
lowercase()
while true do
screen.waitVblankStart(8)
pad = Controls.read()
if pad:up() then
if keyposy==1 then
keyposy = 4
else
keyposy = keyposy-1
end
keysel()
elseif pad:down() then
if keyposy==4 then
keyposy = 1
else
keyposy = keyposy+1
end
keysel()
elseif pad:right() then
if keyposx==3 then
keyposx = 1
else
keyposx = keyposx+1
end
keysel()
elseif pad:left() then
if keyposx==1 then
keyposx = 3
else
keyposx = keyposx-1
end
keysel()
elseif pad:l() then
prints()
elseif pad:r() then
prints()
elseif pad:triangle() then
prints()
elseif pad:circle() then
prints()
elseif pad:cross() then
prints()
elseif pad:square() then
prints()
elseif pad:select() then
if case=="lower" then
uppercase()
elseif case=="upper" then
lowercase()
end
elseif pad:start() then
save.text()
elseif pad:note() then
break
end
end
keyscreen:clear()
screen:flip()
return text
end
how do i give SELECT button 2 functions?
like:
and now when i press SELECT again i want to usbDikModeDeactivate..Code:if pad:select() then
System.usbDiskModeActivate()
end
pls help
i can answer the 2 qestion :
select = 1
if pad:select() then
if select == 1 then
select = 2
System.usbDiskModeActivat e()
end
end
if pad:select() then
if select == 2 then
select = 1
System.usbDiskModeDeactiv ate()
end
end
it doesnt work :/ it doesnt even activate USB :( but still thx for caring
Question 2
Code:UsbOn = 0
if pad:select() and oldpad:select()~=pad:select() and UsbOn == 0 then
select = 1
end
if pad:select() and oldpad:select()~=pad:select() and UsbOn == 1 then
select = 0
end
if UsbOn == 0 then
System.usbDiskModeActivate()
end
if UsbOn == 1 then
System.usbDiskModeDeactivate()
end
thx i will try it!
edit. hmm now it activates USB right after i acces the app, then when i press SELECT i just get Error "oldpad" something...
Heres my full code:
and yeh i just started yesterdayCode:-- Moj prvy LUA program
-- Author: myschoo
-- ******* Variables ********
green = Color.new(0,255,0)
zelena = Color.new(34,70,77)
oranzova = Color.new(214,128,11)
modra = Color.new(0,24,240)
bordova = Color.new(138,0,11)
myschoo = Color.new(236,225,28)
biela = Color.new(255,255,255)
upPressed = 'Drzis sipku nahor'
downPressed = 'Drzis sipku nadol'
leftPressed = 'Drzis sipku dolava'
rightPressed = 'Drzis sipku doprava'
LPressed = 'Drzis "L" tlacitko'
-- *****Main Loop******
while true do
dofile("key.lua")
back = Image.load("blue.jpg")
boltsnd = Sound.load("sound.wav")
screen:blit(0, 0, back)
screen:print(145, 5, 'Podrz START pre vypnutie', biela)
screen:print(155, 15, "Podrz SELECT pre USB", biela)
screen:print(155, 25, "Podrz krizik pre zvuk", biela)
screen:print(145, 35, 'Podrz R+stvorec pre info', biela)
screen:print(145, 45, 'Podrz R+L pre klavesnicu', biela)
pad = Controls.read()
if pad:up() then
screen:print(185,125,upPressed,green)
end
if pad:down() then
screen:print(185,125,downPressed,zelena)
end
if pad:left() then
screen:print(185,125,leftPressed,oranzova)
end
if pad:right() then
screen:print(185,125,rightPressed,modra)
end
if pad:l() then
screen:print(185,125,LPressed,bordova)
end
if pad:r() then
screen:print(185,125,'Drzis "R" tlacitko',green)
end
if pad:triangle() then
screen:print(185,125,'Drzis trojuholnik',zelena)
end
if pad:circle() then
screen:print(185,125,'Drzis kruzok',oranzova)
end
if pad:cross() then
boltsnd:play()
screen.flip()
Music.volume(128)
end
if pad:square() then
screen:print(185,125,'Drzis stvorec',bordova)
end
UsbOn = 0
if pad:select() and oldpad:select()~=pad:select() and UsbOn == 0 then
select = 1
end
if pad:select() and oldpad:select()~=pad:select() and UsbOn == 1 then
select = 0
end
if UsbOn == 0 then
System.usbDiskModeActivate()
end
if UsbOn == 1 then
System.usbDiskModeDeactivate()
end
if pad:start() then
break
end
if pad:square() and pad:r() then
screen:print(175, 255, 'Autor: myschoo', myschoo)
end
if pad:r() and pad:l() then
-- Examples
print(keyboard())
thetext = keyboard()
end
screen.waitVblankStart()
screen.flip()
end
THAT should work. i never got the "oldpad" way myself...lolCode:select_does_this = 1
if pad:select() and select_does_this == 1 then
select_does_this = 2
elseif select_does_this == 2 then
select_does_this = 1
end
if select_does_this == 1 then
System.usbDiskModeDeactivate()
elseif select_does_this == 2 then
System.usbDiskModeActivate()
end
yeh this is quiet better...but there is still problem... well..i press SELECT and my PSP USB activates..thats ok :) but then when i stop holding button USB Deactivates, so basicly i have to hold button to be connected now
thx for help guys i appreciate it! ;)Code:-- Moj prvy LUA program
-- Author: myschoo
-- ******* Variables ********
green = Color.new(0,255,0)
zelena = Color.new(34,70,77)
oranzova = Color.new(214,128,11)
modra = Color.new(0,24,240)
bordova = Color.new(138,0,11)
myschoo = Color.new(236,225,28)
biela = Color.new(255,255,255)
upPressed = 'Drzis sipku nahor'
downPressed = 'Drzis sipku nadol'
leftPressed = 'Drzis sipku dolava'
rightPressed = 'Drzis sipku doprava'
LPressed = 'Drzis "L" tlacitko'
-- *****Main Loop******
while true do
dofile("key.lua")
back = Image.load("blue.jpg")
boltsnd = Sound.load("sound.wav")
screen:blit(0, 0, back)
screen:print(145, 5, 'Podrz START pre vypnutie', biela)
screen:print(155, 15, "Podrz SELECT pre USB", biela)
screen:print(155, 25, "Podrz krizik pre zvuk", biela)
screen:print(145, 35, 'Podrz R+stvorec pre info', biela)
screen:print(145, 45, 'Podrz R+L pre klavesnicu', biela)
pad = Controls.read()
if pad:up() then
screen:print(185,125,upPressed,green)
end
if pad:down() then
screen:print(185,125,downPressed,zelena)
end
if pad:left() then
screen:print(185,125,leftPressed,oranzova)
end
if pad:right() then
screen:print(185,125,rightPressed,modra)
end
if pad:l() then
screen:print(185,125,LPressed,bordova)
end
if pad:r() then
screen:print(185,125,'Drzis "R" tlacitko',green)
end
if pad:triangle() then
screen:print(185,125,'Drzis trojuholnik',zelena)
end
if pad:circle() then
screen:print(185,125,'Drzis kruzok',oranzova)
end
if pad:cross() then
boltsnd:play()
screen.flip()
Music.volume(128)
end
if pad:square() then
screen:print(185,125,'Drzis stvorec',bordova)
end
select_does_this = 1
if pad:select() and select_does_this == 1 then
select_does_this = 2
elseif select_does_this == 2 then
select_does_this = 1
end
if select_does_this == 1 then
System.usbDiskModeDeactivate()
elseif select_does_this == 2 then
System.usbDiskModeActivate()
end
if pad:start() then
break
end
if pad:square() and pad:r() then
screen:print(175, 255, 'Autor: myschoo', myschoo)
end
if pad:r() and pad:l() then
-- Examples
print(keyboard())
thetext = keyboard()
end
screen.waitVblankStart()
screen.flip()
end
It doesn't work right because you don't check for pad:select when select_does_this==2. Also, you'll have to be very quick or just lucky if you don't use the "oldpad" way, because the code might loop more than once while you are pressing the button, so it would change back and forth.Zitat:
Zitat von EminentJonFrost
One of many solutions:
At the top of your code with the rest of the constant definitions, put this:When you want to change the USB mode (inside your loop):Code:oldpad=Controls.read()
usbmode=false
At the bottom of your loop (still inside):Code:if pad:select() and oldpad:select()~=pad:select() then
if usbmode then
System.usbDiskModeDeactivate()
else
System.usbDiskModeActivate()
end
end
Note that the "oldpad" way is just comparing your button presses in the current loop to your button presses in the last loop. If you only want your "if" statement to execute once, then you have to make sure that your button presses in the current loop isn't equal to the ones in your previous loop. This is because code runs so fast that even though you think you are just pressing a button once, the code may loop several times.Code:oldpad=pad