Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Could someone explain the 'i =' thing?

Asked by 10 years ago

I don't get them, what are they and how are they used?

0
I'm afraid this question is very vague, you should try to specify a little further if you want a solid answer. duckwit 1404 — 10y

4 answers

Log in to vote
0
Answered by
Dummiez 360 Moderation Voter
10 years ago

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.

Ad
Log in to vote
0
Answered by 10 years ago

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

Log in to vote
0
Answered by 10 years ago

Instead of i you can use another letter or word.

Log in to vote
0
Answered by
ZeroBits 142
10 years ago

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

Answer this question