| View previous topic :: View next topic |
| Author |
Message |
VgSlag
Joined: 30 Jun 2005 Posts: 43
|
Posted: Sat Mar 25, 2006 4:18 am Post subject: Variable creation |
|
|
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. |
|
| Back to top |
|
 |
JorDy
Joined: 11 Dec 2005 Posts: 121
|
Posted: Sat Mar 25, 2006 4:27 am Post subject: |
|
|
it would proably be best to use a table for that
| Code: |
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 |
|
| Back to top |
|
 |
matriculated
Joined: 04 Mar 2006 Posts: 31
|
Posted: Sat Mar 25, 2006 5:08 am Post subject: |
|
|
| JorDy wrote: | it would proably be best to use a table for that
| Code: |
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. |
|
| Back to top |
|
 |
KawaGeo
Joined: 27 Aug 2005 Posts: 191 Location: Calif Mountains
|
Posted: Sat Mar 25, 2006 5:19 am Post subject: |
|
|
You can start the script zero if you want but Lua likes to start it with a 1 if possible. _________________ Geo Massar
Retired Engineer |
|
| Back to top |
|
 |
|