Variable creation

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

Moderators: Shine, Insert_witty_name

Post Reply
VgSlag
Posts: 43
Joined: Thu Jun 30, 2005 5:36 pm

Variable creation

Post by VgSlag »

How do I go about create variable names out of dynamic elements?

Say I wanted to create 10 vars:

myVar_0 - myVar_9

Using a for loop how would I write this please?

Thanks in advance.
JorDy
Posts: 121
Joined: Sun Dec 11, 2005 8:45 am

Post by JorDy »

it would proably be best to use a table for that

Code: Select all

mayVar_ = {}

for i=1, 10 do
     myVar_[i-1] = ""
end
im sure theres another way to do that but thats the only one i can thing of right now
matriculated
Posts: 31
Joined: Sat Mar 04, 2006 1:35 am

Post by matriculated »

JorDy wrote:it would proably be best to use a table for that

Code: Select all

mayVar_ = {}

for i=1, 10 do
     myVar_[i-1] = ""
end
im sure theres another way to do that but thats the only one i can thing of right now
I don't think your can index an element at 0. It has to start at 1.
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

You can start the script zero if you want but Lua likes to start it with a 1 if possible.
Geo Massar
Retired Engineer
Post Reply