forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Double Arrays

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
paulieweb



Joined: 03 Nov 2005
Posts: 8
Location: PSU

PostPosted: Thu Nov 03, 2005 2:27 pm    Post subject: Double Arrays Reply with quote

Are double arrays possible in lua (ie count[i][j])? I thought I remembered reading they are and set mine up as follows:

marked = {}{} -- initialize

marked[i][j] = 3 --later

and when trying to run on luaplayer i get a general error message, "unexpected symbol near '{' "
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
fullerlee



Joined: 03 Nov 2005
Posts: 54

PostPosted: Thu Nov 03, 2005 4:51 pm    Post subject: Reply with quote

You can do double arrays by treating each row in the first as an array.

eg:
marked[i] = {}
marked[i][j] = 3

I'm no expert, but that's how I've done it in my game.
Back to top
View user's profile Send private message
paulieweb



Joined: 03 Nov 2005
Posts: 8
Location: PSU

PostPosted: Thu Nov 03, 2005 4:58 pm    Post subject: Reply with quote

yea, i found some code online after endless searching. here's mine for starting an array and initializing to zeros, in case it helps anyone

marked = {}
i = 0
while i < 16 do
marked[i] = {}
j = 0
while j < 16 do
marked[i][j] = 0
j = j + 1
end
i = i + 1
end

and thank you for your response
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
fullerlee



Joined: 03 Nov 2005
Posts: 54

PostPosted: Thu Nov 03, 2005 5:03 pm    Post subject: Reply with quote

You know, for loops would be tidier in that situation.

Code:

marked = {}
for i=0,15 do
  marked[i] = {}
  for j=0,15 do
    marked[i][j] = 0
  end
end


Lee
Back to top
View user's profile Send private message
paulieweb



Joined: 03 Nov 2005
Posts: 8
Location: PSU

PostPosted: Sat Nov 05, 2005 1:22 am    Post subject: Reply with quote

but i like while loops, they are friendly
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group