# "lua while loops" Code Answer's

You're definitely familiar with the best coding language Lua that developers use to develop their projects and they get all their queries like "lua while loops" answered properly. Developers are finding an appropriate answer about lua while loops related to the Lua coding language. By visiting this online portal developers get answers concerning Lua codes question like lua while loops. Enter your desired code related query in the search bar and get every piece of information about Lua code related question on lua while loops.

### lua while loops

By brandon_1845#3023 on Apr 03, 2020
``````--// Basic while true do loop

while true do

--// Looped text
print("Looped Text")

--// Time the loop waits before looping again
wait(1)
end``````

5

### while in lua

By Old-fashioned Ostrich on May 13, 2020
``````while(condition)
do
statement(s)
end
``````

Source: www.tutorialspoint.com

2

### lua for loops

By [Nn]uclear\s[Tt]he\s[Nn]oob.* on Dec 31, 2020
``````--[[
There are two types of lua for loops.
There is the generic definition, (pseudo-)expression, increment,
and there is one that allows the use of iterators.
]]

-- The first kind can be used like this:
for a = 0 --[[Define a as 0]], 10 --[[Continue until a reaches 10]], 2 --[[Increment by 2 each iteration]] do
print(a); -- 0, 2, 4, 6, 8, 10.
end

-- The second kind requires an iterator. There are two commonly used built-in ones.
-- pairs and ipairs.

-- pairs uses the built-in next function, which gets the next key in a table given a previous key.
-- pairs can be used both for pure arrays and non-numerical indices (ie. maps).
for i,v in pairs({["A"] = 5, ["B"] = 10}) do
print(i, v); -- A 5, B 10.
end

-- ipairs is different in that it can only loop over tables with numerical indices (ie. arrays) hence the name *i*pairs.
for i,v in ipairs({5, 10}) do
print(i, v); -- 1 5, 2 10.
end

-- https://www.lua.org/pil/7.3.html``````