View Full Version : [i]

03-19-2015, 11:25 PM
What does [i] mean?

Used in a sentense:

if (spellInfo->Effects[i].ApplyAuraName

Thank you in regards

03-19-2015, 11:59 PM
Look up arrays.

03-20-2015, 12:21 AM
[i] or more to the point `i` is a variable that holds a value of either numerical/alpha-numerical or whatever

local Table = {
[1] = "hello I am 1",
[2] = "hello I am 2",
[3] = 3,
[4] = 4,
[5] = "haha im 5",

for i = 1, 5 do

print("i = "..i.." keys to "..Table[i])

in this Lua script above `i` will have a numerical value starting with 1 and increasing to 5
as it loops thru 1 to 5 you will see how Table[i] outputs differently per each loop.

so `i` is being used as a key to access a specific position of stored data.

hope this helps.

oh yea as you get a better understanding of Arrays/tables you will see it does not have to be the letter i , you can use any alpha numerical string as a key as long as it does not conflict with another variable.
e.g. in Guild Warz i use the Guild's name as a key.

--> http://www.cplusplus.com/doc/tutorial/arrays/ <--
this link might help out.

lol and along comes a Tommy lol yea I can do arrays in C++ but i'm faster at Lua :P and the descriptive info you are looking for is the same.
but awwww wheres the fun in yours? it needs sum kewl flashy lights and whistles and fun xD

03-20-2015, 12:29 AM
"i" is a value that returns an element from an array.


int array[] = { 1, 2, 3, 4, 5 };
for (int i = 0; i < 5; i++)
cout << array[i];

Above will print:

1, 2, 3, 4, 5

On a side note: It doesn't necessarily have to be "i". It can be any letter or word you want as long as it doesn't conflict with existing variables or syntax keywords.

For example:

int array[] = { 1, 2, 3, 4, 5 };
for (int element = 0; element < 5; element++)
cout << array[element];

03-20-2015, 05:27 PM
Thanks a bunch guys. :)