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 

Variable creation

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



Joined: 30 Jun 2005
Posts: 43

PostPosted: Sat Mar 25, 2006 4:18 am    Post subject: Variable creation Reply with quote

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
View user's profile Send private message
JorDy



Joined: 11 Dec 2005
Posts: 121

PostPosted: Sat Mar 25, 2006 4:27 am    Post subject: Reply with quote

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
View user's profile Send private message
matriculated



Joined: 04 Mar 2006
Posts: 31

PostPosted: Sat Mar 25, 2006 5:08 am    Post subject: Reply with quote

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
View user's profile Send private message
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Sat Mar 25, 2006 5:19 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
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