![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on A few more questions about Lua... within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Hey all, It's me. Again. I'm having some trouble with tables. There's just something about them that I'm not getting. ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
Hey all,
It's me. Again. I'm having some trouble with tables. There's just something about them that I'm not getting. If y'all knew of any good tutorials for tables used in conjunction with for loops, please let me know. Also, is using lua less RAM-efficient than compiling an EBOOT file using C/C++? If so, how much? Thanks for all the help, y'all, spykr (I just had to fit that smilie in here somewhere. Haha.)
|
|
|
|
|
|
|
#2 |
![]() |
Whats your Problem with tables?
white = Color.new(255,255,255) table = {"h","a","l","l","o"} while true do for i=1, table.getn(table) do screen rint(10,10*i,tabl e[i],white)end screen.flip() screen.waitVblankStart() end |
|
|
|
|
|
#3 | |
![]() |
Quote:
Code:
table.getn(table) The For loop repeats the instructions for all the values starting from 1 to the number of variables in the table. Code:
screen:print(10,10*i,table[i],white) The result will look like this: h.........a.........l.... .....l.........o (pretend the periods aren't there)
__________________
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER] |
|
|
|
|
|
|
#4 |
![]() Ænima
|
Don't forget that tables can contain multiple dimensions and any type.
Code:
table = {}
table[1] = "First Entry In Table"
table[2] = 492.19
table[3] = {}
table[3][1] = "Table[3] is a table on it's own"
table[3][2] = Image.load("Image.png")
table[3][3] = {}
table[3][3][1]"As many dimensions as you want"
table[3][3][2] = Color.new(255,0,0)
table[3][3][3] = {}
table[3][3][1] = "They get confusing after they get so big though"
table[3][3][2] = table[2] * 42
Oh, and yes, Lua usually takes up more RAM, as it's loading every function Lua can handle, even if you're not using it.
__________________
[IMG]http://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Zoso.svg/744px-Zoso.svg.png[/IMG] Looking for some good C programming tutorials for the PSP? Look no further! [URL="http://psp-coding.com/"]PSP-Coding.com[/URL] is your source for all your PSP coding needs. Last edited by Judas; 02-18-2008 at 07:00 AM.. Reason: Automerged Doublepost |
|
|
|
|
|
#5 |
![]() |
|
|
|
|
|
|
#6 | |
|
Quote:
And would it be worth it to rewrite my code in c/c++ for the extra RAM? Because I'm afraid that this program will take up too much of the mem. Last edited by spykr; 02-18-2008 at 11:45 AM.. |
||
|
|
|
![]() |
| Tags |
| lua , questions |
| Thread Tools | |
|
|