Double Arrays

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
paulieweb
Posts: 8
Joined: Thu Nov 03, 2005 10:18 am
Location: PSU
Contact:

Double Arrays

Post by paulieweb »

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

marked = {}{} -- initialize

marked[j] = 3 --later

and when trying to run on luaplayer i get a general error message, "unexpected symbol near '{' "
fullerlee
Posts: 54
Joined: Thu Nov 03, 2005 9:46 am

Post by fullerlee »

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

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

I'm no expert, but that's how I've done it in my game.
paulieweb
Posts: 8
Joined: Thu Nov 03, 2005 10:18 am
Location: PSU
Contact:

Post by paulieweb »

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 = {}
j = 0
while j < 16 do
marked[j] = 0
j = j + 1
end
i = i + 1
end

and thank you for your response
fullerlee
Posts: 54
Joined: Thu Nov 03, 2005 9:46 am

Post by fullerlee »

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

Code: Select all

marked = &#123;&#125;
for i=0,15 do
  marked&#91;i&#93; = &#123;&#125;
  for j=0,15 do
    marked&#91;i&#93;&#91;j&#93; = 0
  end
end
Lee
paulieweb
Posts: 8
Joined: Thu Nov 03, 2005 10:18 am
Location: PSU
Contact:

Post by paulieweb »

but i like while loops, they are friendly
Post Reply