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 EminentJonFrost use an image editing program. i use The GIMP. :) its like Photoshop for the poor! same ...
-
01-27-2007, 01:00 PM #5311QJ Gamer Silver
- Registriert seit
- Aug 2006
- Ort
- The Matrix
- Beiträge
- 1.090
- Points
- 8.002
- Level
- 60
- Downloads
- 0
- Uploads
- 0
same lol!
Zitat von EminentJonFrost
http://i28.tinypic.com/1znoljt.png
lolololololol - Reach 100,000 Gamerscore
-
01-27-2007, 01:01 PM #5312
clipping is a way of only displaying part of an image, the image is not edited so your still able to preform tasks on it or clip other sections:
http://img265.imageshack.us/img265/2...exampledd5.png
...just needed to clear that up.
GuitarGod1134, use the 8th parameter of blit, "alpha" stands for alpha transparency setting it to true makes the lua player read alpha channels make parts of the image transparent, there has to be transparency in the image obviously.
-
01-27-2007, 01:08 PM #5313QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
*just following up with what he's saying*...which is made with an image editor.
Zitat von eyece
ask if you need help on doing it with the Gimp, its really simple.
oh, just a note, to use the gimp you have to get something called GTK+ runtime environment. its on the same site as Gimp, so no worries.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-27-2007, 01:16 PM #5314QJ Gamer Green
- Registriert seit
- Aug 2006
- Ort
- London
- Beiträge
- 165
- Points
- 5.400
- Level
- 47
- Downloads
- 0
- Uploads
- 0
I've just started in Lua an Im making pong.
I'm onto the collision detection, but it doesnt seem to work....
Heres the code:
And heres the full code:Code:function moveBall(paddle ) if (ball[1].x + ballimg:width() < paddle.x) and (ball[1].x > paddle.x + paddleimg:width( )) then ball[1].x = ball[1].x + 2 end if (ball[1].x + ballimg:width( ) > paddle.x ) and (ball[1].x < paddle.x + paddleimg:width( )) then ball[1].x = ball[1].x - 2 end end
Spoiler for Full code:
It hits the right paddle, then just moves back and forth.
How do I fix this?
-
01-27-2007, 01:56 PM #5315QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
i was answering eyece...
Zitat von EminentJonFrost
anyway
DOES ANYONE KNOW HOW TO COPY FILE FROM DIRECTORY1 to DIRECTORY2 ??[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
01-27-2007, 02:11 PM #5316
i want to know this, but just make the image partially transparent so you can fade in and out.
Zitat von GuitarGod1134
i tried what SG57 was saying earlier to fade in and out but it didn't seem to work
-
01-27-2007, 02:20 PM #5317QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
ahh Pong :) that was my first Lua program too :) (PvP Pong)
Zitat von Blake1
let me take a look see.....NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-27-2007, 02:23 PM #5318
i guessDOES ANYONE KNOW HOW TO COPY FILE FROM DIRECTORY1 to DIRECTORY2 ??did not work?Code:System.rename("ms0:/folder0/file.file", ms0:/folder1/file.file")
i don't know, i don't even know how to open/read a file, i have not used those functions yet.
-
01-27-2007, 02:24 PM #5319Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Ill just make the background the same color as my background so it just sinks in.
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
01-27-2007, 03:28 PM #5320QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
it worked in PC..or it looked like it worked but nt very well in PSP
Zitat von eyece
[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
01-27-2007, 03:30 PM #5321QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
Is any body here Good at GFX ? if so please PM me, I need a menu...
Thank youNEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-27-2007, 06:50 PM #5322words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Hey - I need someone to test this out for me...
Save it as .lua nd run it on the PSP... tell me what happens please? An error spat out if there is one as well please.Code:scene = {} scene[1] = {newcolor = {r=0,g=0,b=0,a=0}, finalcolor = Color.new(0,0,0), screencolor = Color.new(0,0,0), image=Image.createEmpty(480,272)} scene[2] = {newcolor = {r=0,g=0,b=0,a=0}, finalcolor = Color.new(0,0,0), screencolor = Color.new(0,0,0), image=Image.createEmpty(480,272)} scene[3] = {newcolor = {r=0,g=0,b=0,a=0}, finalcolor = Color.new(0,0,0), screencolor = Color.new(0,0,0), image=Image.createEmpty(480,272)} scene_num = 1 time = 0 pi = math.atan(1) * 4 i=0 y=0 x=0 while true do for x=0,480 do for y=0,272 do scene[scene_num].screencolor = screen:pixel(x,y) -- get pixel color scene[scene_num].newcolor = scene[scene_num].screencolor:colors() -- give it to new table scene[scene_num].newcolor.a = 255/scene_num-40/scene_num -- edit transparency value scene[scene_num].finalcolor = Color.new(scene[scene_num].newcolor.r,scene[scene_num].newcolor.g,scene[scene_num].newcolor.b,scene[scene_num].newcolor.a) scene[scene_num].image:pixel(x,y,scene[scene_num].finalcolor) -- give that color to the old scene end end scene_num = scene_num + 1 if scene_num > 3 then scene_num = 1 end screen:clear() x = math.sin(pi * 2 / 360 * time) * 150 + 180.5 screen:print(x, 100, "Does this blur?", Color.new(0,255,0)) time = time + 1 if time >= 360 then time = 0 end for i=1,3 do screen:blit(0,0,scene[i].image) end screen.waitVblankStart() screen.flip() end
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-27-2007, 07:38 PM #5323
line 26, argument was incorrect.
its because you have this:screen pixel index only goes to 479 and 271, common mistake.Code:for x=0,480 do for y=0,272 do
-
01-27-2007, 08:19 PM #5324words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Ahh - ok. I thought LUA for loops used a '<' operator on default, i guess its '<=' now. Thanks for that.
Can you test it once its fixed? As in, if anyone else sees it use this please:
That should simulate a 'motion blur' you find in most games for when you get hit of some sort... Note, its not using hardware accelerated blending, so i dont know if this will work as it shuld or not.Code:scene = {} scene[1] = {newcolor = {r=0,g=0,b=0,a=0}, finalcolor = Color.new(0,0,0), screencolor = Color.new(0,0,0), image=Image.createEmpty(480,272)} scene[2] = {newcolor = {r=0,g=0,b=0,a=0}, finalcolor = Color.new(0,0,0), screencolor = Color.new(0,0,0), image=Image.createEmpty(480,272)} scene[3] = {newcolor = {r=0,g=0,b=0,a=0}, finalcolor = Color.new(0,0,0), screencolor = Color.new(0,0,0), image=Image.createEmpty(480,272)} scene_num = 1 time = 0 pi = math.atan(1) * 4 i=0 y=0 x=0 while true do for x=0,479 do for y=0,271 do scene[scene_num].screencolor = screen:pixel(x,y) -- get pixel color scene[scene_num].newcolor = scene[scene_num].screencolor:colors() -- give it to new table scene[scene_num].newcolor.a = 255/scene_num-40/scene_num -- edit transparency value scene[scene_num].finalcolor = Color.new(scene[scene_num].newcolor.r,scene[scene_num].newcolor.g,scene[scene_num].newcolor.b,scene[scene_num].newcolor.a) scene[scene_num].image:pixel(x,y,scene[scene_num].finalcolor) -- give that color to the old scene end end scene_num = scene_num + 1 if scene_num > 3 then scene_num = 1 end screen:clear() x = math.sin(pi * 2 / 360 * time) * 150 + 180.5 screen:print(x, 100, "Does this blur?", Color.new(0,255,0)) time = time + 1 if time >= 360 then time = 0 end for i=1,3 do screen:blit(0,0,scene[i].image) end screen.waitVblankStart() screen.flip() end
So? can anyone test it and tell me what it does?
-= Double Post =-
I just tested it on WLP, and it doesnt support alpha values other than 255 or 0, so it obviously looks messed. But, the framerate was slow,...Geändert von SG57 (01-27-2007 um 08:19 PM Uhr) Grund: Automerged Doublepost

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-27-2007, 08:31 PM #5325
i tried it on luaplayer windows and it says:
error: script.lua:26: An argument was incorrect
a.k.a.
scene[scene_num].screencolor = screen
ixel(x,y) -- get pixel color
i'm using luaplayer.20; and the error it is picking up is the screen
ixel(x,y) i'm not sure if this luaplayer version just doesn't know the command or something. if i get the chance i'll test it on my psp too though. but i'm going to sleep.
-
01-27-2007, 08:51 PM #5326
i tried it SG57, it was indeed slow on the psp, about 1 frame every 2 minutes actually :P
but from what i could see (1 line of text) it did blur.
-
01-27-2007, 10:12 PM #5327words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
emerica - I know, read the post above yours.
eyece - Yes, i expected it to blurr (since whilst programming it, it all seemed to add up to motion blurr) but its those damn for loops killing myspeed. 480*272*n frames = total # of cycles... Im going to think up a way to get the screens colors without hte massive for loop...
Ill post back here with a new version, so please someone stay on? It should only take ~5 minutes.
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-27-2007, 10:43 PM #5328QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- 6ft. Down Underground........Oh and guess what my avatar is
- Beiträge
- 387
- Points
- 4.918
- Level
- 44
- Downloads
- 0
- Uploads
- 0
Can lua right to flash 0? and 1?
-
01-27-2007, 10:44 PM #5329words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Ok...
Someone test this please?
This runs at a very decent framerate on my PCCode:scene = {} scene[1] = {newcolor = {r=0,g=0,b=0,a=0}, finalcolor = Color.new(0,0,0), screencolor = Color.new(0,0,0), image=Image.createEmpty(480,13)} scene[2] = {newcolor = {r=0,g=0,b=0,a=0}, finalcolor = Color.new(0,0,0), screencolor = Color.new(0,0,0), image=Image.createEmpty(480,13)} scene[3] = {newcolor = {r=0,g=0,b=0,a=0}, finalcolor = Color.new(0,0,0), screencolor = Color.new(0,0,0), image=Image.createEmpty(480,13)} scene_num = 1 time = 0 pi = math.atan(1) * 4 i=0 y=0 x=0 while true do for x=0,479 do for y=130,142 do scene[scene_num].screencolor = screen:pixel(x,y) -- get pixel color scene[scene_num].newcolor = scene[scene_num].screencolor:colors() -- give it to new table scene[scene_num].newcolor.a = 255/scene_num-40/scene_num -- edit transparency value scene[scene_num].finalcolor = Color.new(scene[scene_num].newcolor.r,scene[scene_num].newcolor.g,scene[scene_num].newcolor.b,scene[scene_num].newcolor.a) scene[scene_num].image:pixel(x,y-130,scene[scene_num].finalcolor) -- give that color to the old scene end end scene_num = scene_num + 1 if scene_num > 3 then scene_num = 1 end screen:clear() x = math.sin(pi * 2 / 360 * time) * 150 + 180.5 screen:print(x, 131, "Does this blur?", Color.new(0,255,0)) time = time + 1 if time >= 360 then time = 0 end for i=1,3 do screen:blit(0,130,scene[i].image) end screen.waitVblankStart() screen.flip() end
-= Double Post =-
theundead - not that i know of. Itd be a quick fix though, Im sure i could quickly write up a lua command for it...Geändert von SG57 (01-27-2007 um 10:44 PM Uhr) Grund: Automerged Doublepost

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-27-2007, 10:52 PM #5330lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Its running super slow on the PSP.
-
01-27-2007, 11:09 PM #5331words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Somehow I doubt you even tried it. Tell me what it looks like... Does it blurr or print anything at all?

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-27-2007, 11:10 PM #5332lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
It prints a green text in the middle of the screen thats says "does this blur?" then it starts to blur, But at a really slow rate
You thought i didn't try it?
-
01-27-2007, 11:25 PM #5333words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
I have no way to tell if you did try it. One reason is because all youve said can easily be obtained just by reading the middle of my code, and my post. And another way is because it says "Does this blur?", not lowercase d.
-= Double Post =-
Also, not to be mean, but whatd you do to get Dev status? I cant recall seeing your name pop up with a game... Like, for yoursam its Wedge Racer, AhMan its irshell, etc.Geändert von SG57 (01-27-2007 um 11:25 PM Uhr) Grund: Automerged Doublepost

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-27-2007, 11:25 PM #5334
it works awesome, SG57 though i couldn't for the life of me get it to fully clear the screen so i didn't keep getting a clip of lowser in the background (witch was also being blurred), sweet script, whats it for anyway.
-
01-27-2007, 11:31 PM #5335words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
eyece - You mean to say it actually works? :) I was going to use it in my FPS Call of Duty 2 - PSP Edition for when you get hit, and for when you die. As for hte clipping of lowser in the background... Add this BEFORE the while true do loop and tell me if it fixes it
That should remove any lowser residue.Code:screen:clear() screen.waitVblankStart() screen.flip()
Think you could video or describe how it is? Id like to know more..
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-27-2007, 11:32 PM #5336lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Well i didnt think i had to exactly match wording, If i did read the middle of your code, Dont you think i would have gotten it right? I did run it, But it took a long time for it to blur, then after letting it run for awhile you couldnt tell what was one the screen cause it blurred so much.
-
01-27-2007, 11:40 PM #5337
:/ i didn't post this yet... and i sure as hell didn't do it twice :Pwait, you have yet to see it in action? :/
lost your psp or something?
ill get a screen of it on the psp, i want to see it as if full speed, so i'm gonna save to file and make it into a gif.
-= Double Post =-
wait, you have yet to see it in action? :/
lost your psp or something?
I tried clearing / flipping the screen first, it did not work for some reason.
ill get a screen of it on the psp, i want to see it as if full speed, so i'm gonna save to file and make it into a gif.Geändert von eyece (01-27-2007 um 11:42 PM Uhr) Grund: Automerged Doublepost
-
01-27-2007, 11:44 PM #5338words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
I dont have a PSP... I lost it. Everything ive devd is PSPless. Hopefully people see that as a handicap for me.

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-27-2007, 11:49 PM #5339
ta-da!:
http://img201.imageshack.us/img201/8...mation1gk6.gif
edit:
ouch, your like a mozart of homebrew.
-
01-28-2007, 12:19 AM #5340QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
sounds like all he needs to do to speed it up is increase an integer somewhere, not sure though cuz I did not run it nor did look at the code, best of luck
Zitat von Anti-QJ
Can't wait to see that effect in action.
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:


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