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; Hey everyone, hopefully I didn't miss this in the 300 pages worth of discussions we've got here, but can someone ...
-
07-31-2006, 08:37 PM #3031
- Registriert seit
- Mar 2006
- Beiträge
- 8
- Points
- 4.143
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Hey everyone, hopefully I didn't miss this in the 300 pages worth of discussions we've got here, but can someone explain to me how to use transparencies with LUA?
-
08-01-2006, 06:32 AM #3032sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
ok, just make your picture delete the part you dpnt want seen, then save it as a .png <-- MOST IMPORTATNT STEP RIGHT THERE
-
08-01-2006, 08:34 AM #3033QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
grimfate please explain a bit clear what your dong but one quick suggestion is that in your code
name[a] = Image.load("header..a..". png)
put a " in it so it looks like this
name[a] = Image.load("header"..a.." .png")
-
08-01-2006, 08:51 AM #3034words 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
Easy... Get some image editor that supports adding an alpha layer, then add one to a PNG, and erase w/e to transparency ;)
Zitat von Makubesu

...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
-
08-01-2006, 09:02 AM #3035QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
hey sg57 could you please help me with my lua animation code coz i cannot get it right
-
08-01-2006, 09:06 AM #3036
- Registriert seit
- Mar 2006
- Beiträge
- 8
- Points
- 4.143
- Level
- 40
- Downloads
- 0
- Uploads
- 0
*tries it out*
Wow, it even supports png-24, this is great! Thanks for your help.
-
08-01-2006, 10:16 AM #3037Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
that wont work cause 'header' has been gotten from the function, hence putting it in "" would make the image: header1.png/header2.png etc. instead of the header that i gave the function.
Zitat von mark.sparky
explainition:
ok, i want to load these images:
test1.png all the way to test6.png
char1.png to char9.png
AND
misc1.png to misc5.png
i want them in their own arrays. so i made a function:
so that i could call it like this:Code:function make(header, frames, name) name = {} for a = 1, frames do name[a] = Image.load(header..a..".png") end end
BUT, i have a prob.Code:make(test, 6, test_array) make(char, 9, char_array) make(misc, 5, misc_array)
when i say :
i want the name of that array to be whatever i give to that function (such as test_array, char_array, and misc_array) BUT, the function make an array named "name" insted of test_array... etc.Code:name = {}
i want it so that the array is named what i give the function.
P.S. sry, its confusing i know.--------------------------------------------------------------------------------------
-
08-01-2006, 10:34 AM #3038QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
why do you want the test_array etc to be called "name" or something else
Geändert von mark.sparky (08-01-2006 um 10:38 AM Uhr)
-
08-01-2006, 12:47 PM #3039Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von mark.sparky
???
OK, try TWO- ACTION!
i am making an app. for it i need to load these images:
i want all those images in an array called:Code:test1.png test2.png test3.png test4.png test5.png test6.png
Code:test_array
then i have ANOTHER set of images:
Code:char1.png char2.png char3.png char4.png char5.png char6.png char7.png char8.png char9.png
i want these images in an array called:
Code:char_array
i have a THIRD set of images (the last set):
i want these images in an array called:Code:misc1.png misc2.png misc3.png misc4.png misc5.png
NOW.. i can make all the arrays and load the images by hand but its MUCH faster with a function, SO i made a function to make the array, and load the images into it:Code:misc_array
NOW, i called the function like thisCode:function make(header, frames, name) name = {} for a = 1, frames do name[a] = Image.load(header..a..".png") end end
BUT, the function does not work properly. the problem is that everytime i call it the function makes an array by the name of:Code:make(test, 9, test_array) make(char, 6, char_array) make(misc, 5, misc_array)
and not the name i give it. (such as test_array, or char_array, or misc_array)Code:name
NOW do u get it?
BTW, i wont tell what app im making yet. ;)--------------------------------------------------------------------------------------
-
08-01-2006, 02:00 PM #3040
- Registriert seit
- Aug 2006
- Beiträge
- 12
- Points
- 3.858
- Level
- 39
- Downloads
- 0
- Uploads
- 0
this is for Grimfate
I think this link could be handy:
http://www.lua.org/pil/14.1.html
I've used that before to dynamically create the name of variables, and I think that's what you want to do, right?
-
08-01-2006, 02:21 PM #3041Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
@grimfate
I think the problem is that since you have that "name={}" line inside the function definition, it overwrites the input variable passed to the function. I'm pretty sure that if you initialize the arrays outside of the function (right before you call the function), then pass the name of the array into the function, it will work. Does that even make sense? :)
Basically, what I'm trying to say is change the "make" function to this:
And then call it like this:Code:function make(header, frames, name) for a = 1, frames do name[a] = Image.load(header..a..".png") end end
At least, that makes sense in my head.Code:test_array={} char_array={} misc_array={} make(test, 9, test_array) make(char, 6, char_array) make(misc, 5, misc_array)
-
08-01-2006, 03:08 PM #3042
- Registriert seit
- Mar 2006
- Beiträge
- 8
- Points
- 4.143
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Won't the array generated by your function only be local to that function anyways? Give the function a return value, and call it like this:
char_array = {}
char array = make(char, 6)
would be my advice.
-
08-01-2006, 03:27 PM #3043Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
EDIT: Ah, sorry about that Makubesu, you were right! I forgot that "name" was a function input variable, which are indeed local to the function no matter how you define them inside there.
Zitat von Makubesu
Geändert von LMelior (08-01-2006 um 05:09 PM Uhr)
-
08-01-2006, 03:32 PM #3044Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
LMelior, and Makubesu both of your ideas are good, BUT the nature on my program NEEDS those arguments to be inside a function.
sry, i cant tell u what im working on yet. sry.
xiringu: ill read that and get bak 2 u. thx!--------------------------------------------------------------------------------------
-
08-01-2006, 05:34 PM #3045Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Oh I don't mind not knowing, but the result of the code that Makubesu described is exactly what you asked for - arrays of images that are named exactly as you wanted them.
Zitat von Grimfate126
The exact results of the code you posted are in three empty, global tables named "test_array," "char_array," and "misc_array," plus a table called "name" with 9 images that is local to the "make" function. The first five images will be your miscellaneous images, the sixth image will be the last character image, and the last three images will be your last three test images.
The exact results of the following code are three global tables with the same names as above with 9, 6, and 5 images, respectively:
You do realize that if you use your current "make" function elsewhere, you could use this code and rename the function? I can't really think of any other situation in which you'd absolutely need those three inputs.Code:function make(header, frames) local name={} for a = 1, frames do name[a] = Image.load(header..a..".png") end return name end ------ test_array=make(test,9) char_array=make(char,6) misc_array=make(misc,5)
-
08-01-2006, 05:45 PM #3046Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von LMelior
yes, i totally understand. but ill release it soon once i get this prob fixed. any more ideas?--------------------------------------------------------------------------------------
-
08-02-2006, 01:44 AM #3047QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
can someone tell me what is worng with this code coz when i run it it says on line 49 'end expected (to close to 'whle' at lin 27 ) near 'elseif':
hear is my code. line 49 and 27 is marked out.
--function for movement and animation
function moveAni()
Code:while pad:down() do -- line 27 animation = animation + 1 link[1].face = down link[1].y = link[1].y + 0.5 if animation <= 6 then screen:blit( link[1].x, link[1].y, down1) end if animation >= 7 and animation < 14 then down1:clear(down2) end if animation >= 14 and animation < 21 then down2:clear(down3) end if animation >= 21 and animation < 28 then down3:clear(down4) end if animation >= 28 and animation < 35 then down4:clear(down1) end if animation == 35 then animation = 7 end elseif link[1].face == down then -- line 49 screen:blit( link[1].x, link[1].y, down1) animation = 0 end end while pad:up() do animation = animation + 1 link[1].face = up link[1].y = link[1].y - 0.5 if animation <= 6 then screen:blit( link[1].x, link[1].y, up1) end if animation >= 7 and animation < 14 then up1:clear(up2) end if animation >= 14 and animation < 21 then up2:clear(up3) end if animation >= 21 and animation < 28 then up3:clear(up4) end if animation >= 28 and animation < 35 then up4:clear(up1) end if animation == 35 then animation = 7 end elseif link[1].face == up then screen:blit( link[1].x, link[1].y, up1) animation = 0 end end while pad:right() do animation = animation + 1 link[1].face = right link[1].x = link[1].x + 0.5 if animation <= 6 then screen:blit( link[1].x, link[1].y, right1) end if animation >= 7 and animation < 14 then right1:clear(right2) end if animation >= 14 and animation < 21 then right2:clear(right3) end if animation >= 21 and animation < 28 then right3:clear(right4) end if animation >= 28 and animation < 35 then right4:clear(right1) end if animation == 35 then animation = 7 end elseif link[1].face == right then screen:blit( link[1].x, link[1].y, right1) animation = 0 end end while pad:left() do animation = animation + 1 link[1].face = down link[1].x = link[1].x - 0.5 if animation <= 6 then screen:blit( link[1].x, link[1].y, down1) end if animation >= 7 and animation < 14 then down1:clear(down2) end if animation >= 14 and animation < 21 then down2:clear(down3) end if animation >= 21 and animation < 28 then down3:clear(down4) end if animation >= 28 and animation < 35 then down4:clear(down1) end if animation == 35 then animation = 7 end elseif link[1].face == down then screen:blit( link[1].x, link[1].y, down1) animation = 0 end end end
-
08-02-2006, 01:47 AM #3048i wish i was cool
- Registriert seit
- Oct 2005
- Ort
- The Netherlands
- Beiträge
- 1.257
- Points
- 8.661
- Level
- 62
- Downloads
- 0
- Uploads
- 0
look at line 49.
Zitat von mark.sparky
-
08-02-2006, 03:01 AM #3049QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
ok thnx ill try that
-= Double Post =-
that doesnt work coz now it says "line 50 erorr: 'end' expected (to colse function at line 25) near 'elseif'Geändert von mark.sparky (08-02-2006 um 03:01 AM Uhr) Grund: Automerged Doublepost
-
08-02-2006, 03:39 AM #3050i wish i was cool
- Registriert seit
- Oct 2005
- Ort
- The Netherlands
- Beiträge
- 1.257
- Points
- 8.661
- Level
- 62
- Downloads
- 0
- Uploads
- 0
oh, I don't know what's the problem then, sorry. maybe put the end under the animation = 0 line at line 49?
-
08-02-2006, 03:43 AM #3051QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
but if i do that then it will end that function will it not
-
08-02-2006, 03:47 AM #3052i wish i was cool
- Registriert seit
- Oct 2005
- Ort
- The Netherlands
- Beiträge
- 1.257
- Points
- 8.661
- Level
- 62
- Downloads
- 0
- Uploads
- 0
probably.
-
08-02-2006, 04:24 AM #3053is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
well. It means you have missed out an end somewhere
What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
08-02-2006, 04:36 AM #3054QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
well alex can you look at the code
-
08-02-2006, 04:40 AM #3055is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
ok, what page is it on?
-= Double Post =-
im leaving any second now, soo i might now have time to helpGeändert von Glynnder (08-02-2006 um 04:40 AM Uhr) Grund: Automerged Doublepost
What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
08-02-2006, 04:50 AM #3056Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
The problem is that you end all of your "if" statements. You can't have an "elseif" if there are no open "if" statements. You aren't using "elseif" correctly. The reason it is good to use "elseif" is because the first time that any one of those statements triggers, the code will skip the rest of the "elseif" choices.
So, the best way for your code to be written is:
To answer your question directly, you did not need an extra end there, but you should have taken the one that was there out! But it would be easier to understand if you wrote it as above.Code:if a then -- do one thing elseif b then -- do something else elseif c then -- do something else else -- do the default action end
-
08-02-2006, 05:54 AM #3057QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
bu the only probably them with that is that i have started the whole animation with a while loop. So cna you not write elseif in a whlie loop
-
08-02-2006, 06:04 AM #3058Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Yes, you can. I recommend using an editor that has syntax highlighting and automatic tabs, because it makes finding errors like that a ton easier. Take a look at the following: no more forgetting what "end" goes with what function.
Zitat von mark.sparky
Code:while pad:down() do if a then -- do one thing elseif b then -- do something else elseif c then -- do something else else -- do the default action end end
-
08-02-2006, 06:11 AM #3059QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
ok ill try that and i use Context text editor
-
08-02-2006, 06:18 AM #3060is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
how would i send a file with IrDA?
-= Double Post =-
load it into and agrgument and then save the arugument to the other PSP?
would that work.
-= Double Post =-
so
gogo = file.ioopen(entry.name)
system.irdawrite(gogo)
blah blah
then on the other PSP
blah blah.
system.idraread(gogo)
file.iosave(gogo)Geändert von Glynnder (08-02-2006 um 06:18 AM Uhr) Grund: Automerged Doublepost
What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe


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