Thread Tools Display Modes
Prev Previous Post   Next Post Next
03-23-18, 10:14 AM   #1
doofus
A Chromatic Dragonspawn
Join Date: Feb 2018
Posts: 158
Pulling my hair with LUA

If I have this structure

mydata = { "one", "two", "three", "four" };

How do I iterate through it? How do I add a value if I want to?

I am thinking of iterating like mydate[1], mydata[2] etc but the for loop syntax confuses me.

In C it might look like this
for i = 1, 50 do
if ( mydata[i] == somevalue ) then return/break/whatever; -- we already have it
end

if ( i == 51 ) then ... -- we do not have it, add it
mydata[51] = somevalue;
end

I am not intending to remove just to add and then at some time wipe the lot and start again.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Pulling my hair with LUA


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off