I don't get them, what are they and how are they used?
COMMUNITY QUESTION
Could someone explain the 'i =' thing?
4 answers
The variable 'i' is commonly used in subscripts and other sets, often in math. When used in a loop for example:
for i = 1, 3 do
print('Number: ' ..i)
end
Variable i will be substituted as the number, and the value for 'i' increments every time it changes.
Also, 'i' stands for index, or iterator.
If I am correct its just a short way of defining a variable. for example.
i = 2+2
h = i*2
end
don't want to embarrrass myself, hope thats correct
Instead of i you can use another letter or word.
Well, for "for" loops i is the common iterator, i = 1 means that i is equal to 1,
for i = 1, 10 do -- i is just a variable name, you can name it anything
print(i) -- every time the script runs i is incremented by 1 (or any other number, if You do that)
end
the "i" can be anything, so this will work too:
for spaghetti = 1, 10 do
print(spaghetti)
end
the number after the variable is just what number it starts at, for example
for spaghetti = 15, 10 do -- the loop will start at 15, and iterate by 1(or -1) until it reaches 10
print(spaghetti)
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I'm afraid this question is very vague, you should try to specify a little further if you want a solid answer.