Lua Programming Help Thread
This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Zitat von bronxbomber92 can any help me with making text return once is hit the edge off the screen? so ...
-
05-15-2006, 12:20 PM #2281QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
I think this should do it.
Zitat von bronxbomber92
What I didnt put is how 'x' changes its value. That, is up to you. :icon_wink
Code:white = Color.new(255, 255, 255) x = 100 y = 100 function add_to_x() blah blah end function subtract_from_x() blah blah end while true do screen:clear() if x <= 0 then add_to_x() -- [reverse whatever code you have manipulating 'x's value] end if x >= 480 then subtract_from_x() -- [go back to original manipulating code] end screen:print(x, y, "Text", white)
Geändert von EminentJonFrost (05-15-2006 um 12:23 PM Uhr)
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-15-2006, 12:38 PM #2282sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
what would go in the "blah, blah"?
Zitat von EminentJonFrost
-
05-15-2006, 01:16 PM #2283
I have a question:
How can i make a picture disapear when i press a button like cross ?Bequiet!!!
I'm learning cc©cc
-
05-15-2006, 01:41 PM #2284sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
probably somwthing like this
Code:if pad:cross() then screen:clear() end
-
05-15-2006, 01:49 PM #2285QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Zitat von EminentJonFrost
How x changes value.
Zitat von bronxbomber92
-
05-15-2006, 01:55 PM #2286QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 55
- Points
- 4.899
- Level
- 44
- Downloads
- 0
- Uploads
- 0
ok my new game is going to be a car game. i want to know how you would make it so if you hit the top, bottom, or sides of the other car your health is decreased. how would i do that?
-
05-15-2006, 02:01 PM #2287
kinda helpfull but what about if there is 3 pictures, and i want to disable 1 when cross is pressed?
Zitat von bronxbomber92
also
this code will make the 2 pictures to keep changing but the problem is that it effect when they move too.Code:if pad:up() then screen:blit(x0, y0, up2) screen:flip() screen.waitVblankStart(10) screen:clear(black) screen:blit(x0, y0, up1) screen:flip() screen.waitVblankStart(10) screen:clear(black) y0 = y0 - 5.1 end
Can you help me making the both picture keep changing while pressing up and not make them to keep skipping to move up ?Geändert von natan333 (05-15-2006 um 02:04 PM Uhr)
Bequiet!!!
I'm learning cc©cc
-
05-15-2006, 02:06 PM #2288sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
if you want to clear one imahe hen use this
if pad:cross() then
screen:clear(--your image--)
end
-
05-15-2006, 02:41 PM #2289Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
hi all, i need help. i want to load many images with one command.i tried this:
the images are: ct1.png, ct2.png... all the way to 300. BUT when i start it, luaplayer says it had an error loading this image.Code:ct = {} for a = 1, 300 do ct[a] = Image.load("ct..a...png") end
pls help me!--------------------------------------------------------------------------------------
-
05-15-2006, 02:57 PM #2290
It has to be this:
You forgot two quotationsCode:ct = {} for a = 1, 300 do ct[a] = Image.load("ct"..a..".png") endLUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
05-15-2006, 02:58 PM #2291QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
how about taking out two of the periods.
Zitat von Grimfate126
like:
...unless the names of your images have two periods after the numbers, then I dont know.Code:ct[a] = Image.load("ct..a.png")[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-15-2006, 03:01 PM #2292
no you need two periods to concatenate.
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
05-15-2006, 03:01 PM #2293Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von EminentJonFrost
nope, ur and altairs method dont work. i think there was another guy who asked this, and pspmillionaire side you had to use a "tostring" function to get it to work. i cant find that page tho.
--------------------------------------------------------------------------------------
-
05-15-2006, 03:05 PM #2294
doesn't work? Do you have the pics in the same folder as the lua file?Code:ct = {} for a = 1, 300 do ct[a] = Image.load("ct"..a..".png") endLUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
05-15-2006, 03:08 PM #2295Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Altair
wow, now that works.. weird. thx!--------------------------------------------------------------------------------------
-
05-15-2006, 04:00 PM #2296
not weird at all. And no prob! What was it? the quotations or the place of the pics? If you want i can explain it.
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
05-15-2006, 04:06 PM #2297Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
i havent the sligest idea. first it didnt work i copied your code. and bam, it worked. YOUR MAGIC. :Jump: :Jump:
Zitat von Altair
--------------------------------------------------------------------------------------
-
05-15-2006, 04:16 PM #2298
abracadabra!
hehe, nice to hearLUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
05-15-2006, 04:18 PM #2299QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
oh...i get it now.
i didnt know that worked with images too...
Does it pretty much work wherever qoutation marks are used?[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-15-2006, 04:23 PM #2300Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Okay this is getting on my last nerve.... ive tried a MILLION things and it wont do what i want it to do... i need to have it so when I press triangle it plays it back. But currently i have to hold it. also whenever i playback once it wont work again, ill have to restart the app to make it playback again... oh and it only plays 3 frames not 6
Code:System.usbDiskModeActivate() oldpad = Controls.read() red = Color.new(255,0,0) black = Color.new(0,0,0) white = Color.new(255,255,255) f = {} f[1] = Image.load("frame#1.png") f[2] = Image.load("frame#2.png") f[3] = Image.load("frame#3.png") f[4] = Image.load("frame#4.png") f[5] = Image.load("frame#5.png") f[6] = Image.load("frame#6.png") canvas = Image.createEmpty(480, 272) canvas:clear(white) x0 = 200 y0 = 200 x1 = 100 y1 = 100 frame = 0 speed = 1 counter = 0 function playback() counter = counter + speed if counter == 1 then screen:blit(0,0, f[1]) screen.flip() screen.waitVblankStart(5) elseif counter == 2 then screen:blit(0,0,f[2]) screen.flip() screen.waitVblankStart(5) elseif counter == 3 then screen:blit(0,0, f[3]) screen.flip() screen.waitVblankStart(5) elseif counter == 4 then screen:blit(0,0,f[4]) screen.flip() screen.waitVblankStart(5) elseif counter == 5 then screen:blit(0,0, f[5]) screen.flip() screen.waitVblankStart(5) elseif counter == 6 then screen:blit(0,0, f[6]) screen.flip() screen.waitVblankStart(5) end end while true do --MAIN LOOP canvas:print(2, 20, "Frame: " .. frame, black) pad = Controls.read() dx = pad:analogX() if math.abs(dx) > 32 then x0 = x0 + dx / 64 end dy = pad:analogY() if math.abs(dy) > 32 then y0 = y0 + dy / 64 end if pad:cross() then canvas:drawLine(x0, y0, x1, y1, black) end if pad:r() and oldpad:r() ~= pad:r() then frame = frame + 1 screen:save("frame#" .. frame.. ".png") canvas:clear(white) end if pad:triangle() then playback() end if pad:square() then canvas:clear(white) end if pad:start() then break end x1 = x0 y1 = y0 screen:blit(0, 0, canvas, 0, 0, canvas:width(), canvas:height(), false) screen:drawLine(x1 - 5, y1, x1 + 5, y1, red) screen:drawLine(x1, y1 - 5, x1, y1 + 5, red) screen.waitVblankStart() screen.flip() oldpad = pad end
--XBL Gamertag: PhenoM904--
-
05-15-2006, 04:24 PM #2301
yep, exactly. But also if you want to put multiple vars after eachother.
Zitat von EminentJonFrost
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
05-15-2006, 04:27 PM #2302
I posted 1 page bellow but i dont think someone will understand it.Code:if pad:up() then screen:blit(x0, y0, up2) screen:flip() screen.waitVblankStart(10 ) screen:clear(black) screen:blit(x0, y0, up1) screen:flip() screen.waitVblankStart(10 ) screen:clear(black) y0 = y0 - 5.1 end
The thing i want to do is:
make picture up1 and up2 to keep changing after like 1 second (nonstop) if i hold up pad and while i m holding up pad, both pictures move up with out messing up other pictures and the moves.
the thing i dint like the "screen.waitVblankStart(1 0)" is that it will also skip some areas when its going up and it effects other pictures that is placed in the screen.
can someone help?Geändert von natan333 (05-15-2006 um 04:29 PM Uhr)
Bequiet!!!
I'm learning cc©cc
-
05-15-2006, 04:32 PM #2303QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
try that.
Zitat von MaSt3r_ShAk3
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-15-2006, 04:36 PM #2304QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
I saw somewhere in an earlier post that that can make it clear just what is specified.Code:if pad:up() then screen:blit(x0, y0, up2) screen:flip() screen.waitVblankStart(10 ) screen:clear(up2) screen:blit(x0, y0, up2) screen:flip() screen.waitVblankStart(10 ) screen:clear(up1) y0 = y0 - 5.1 end
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-15-2006, 04:50 PM #2305Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
doesnt work... it plays a frame real quick n ya...
Zitat von EminentJonFrost

--XBL Gamertag: PhenoM904--
-
05-15-2006, 04:57 PM #2306QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
oh yea, make the "play_back = false" outside the "while true do" loop.
Zitat von MaSt3r_ShAk3
sorry about that.
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-15-2006, 05:02 PM #2307Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
it works! but playback only works once :Argh: :Argh: like i can still draw frames etc. but if i hit triangle after it plays back once it wont work! this is the main problem ive been having!

--XBL Gamertag: PhenoM904--
-
05-15-2006, 05:04 PM #2308
Zitat von bronxbomber92
the clear gave me a red screen, and dint made the picture awayCode:screen:blit(x0, y0, player1) screen:blit(300, 100, player2) if pad:up() then screen:clear(player2) end
Bequiet!!!
I'm learning cc©cc
-
05-15-2006, 05:05 PM #2309sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
sry, then i dont know
-
05-15-2006, 05:31 PM #2310
i did something 2 times but forgot instant :icon_mad: :Cry: that false made the picture to dissapear.
Zitat von bronxbomber92
when i try to put like
"player1 = false" , it gives me error
Bequiet!!!
I'm learning cc©cc


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum