Search
 
SCRIPT & CODE EXAMPLE
 

LUA

lua for loop

-- For K,V in table
for k,v in pairs(tbl) do
 print(k)
 print(v)
end
-- For i=0, num
for i=0, num do
 print(i)  
end
Comment

lua while loops

--// Basic while true do loop

while true do
	
	--// Looped text
	print("Looped Text")
	
	--// Time the loop waits before looping again
	wait(1)
end
Comment

For loop lua

for startValue, EndValue, [increments] do
        --code to execute
end
--The increments value is optional.  If it isn't defined, it is assumed to be "1"
Comment

Lua for loop

for <init>,<max/min value>, <increment> [default is 1]
do
   statements
end

-- Example
for i=1, 5, 1
do
   print(i)
end

--Output
1
2
3
4
5
Comment

lua how to make a loop

for init,max/min value, increment
do
   statement(s)
end
Comment

for loop lua

for x = 0, 10, 1 do
	print(x)
end
Comment

lua for loops

--[[
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

-- You can read more about iterators here:
-- https://www.lua.org/pil/7.3.html
Comment

for loop lua

local t = {}
for index, value in ipairs(t) do
	print(index, value)
end
Comment

for loop lua

local t = {}
for key, value in pairs(t) do
	print(key, value)
end
Comment

lua loop

while wait() do
Comment

lua loop

while true do
-- Put what you want looped in here
-- Do mind that this doesn't work for roblox and for that you should be using the roblox devforum.
end
Comment

PREVIOUS NEXT
Code Example
Lua :: countif excel 
Lua :: how to access an index of a table lua 
Lua :: lua oop 
Lua :: hello world in lua 
Lua :: wait for player character roblox 
Lua :: Roblox Luau Wait Alternative 
Lua :: while loop in lua 
Lua :: roblox get how many players in server 
Lua :: lua difference between pairs and ipairs 
Lua :: fivem lua set player bucket 
Lua :: roblox create part script 
Lua :: swap number in lua 
Lua :: get player who clicked clickdetecter roblox 
Lua :: how to activate a command if someone wears a accessory in lua roblox 
Matlab :: matlab plot vertical line 
Matlab :: matlab random 
Matlab :: Load .mat data in Matlab 
Basic :: cmd cant change directory 
Basic :: xolo themeforest 
Elixir :: elixir string to datetime 
Elixir :: phoenix query get first record 
Elixir :: elixir function guards 
Scala :: scala remove element from list 
Actionscript :: bs modal is working but not visible 
Excel :: google sheets count dates that fall within date range 
Perl :: perl until loop 
Pascal :: pascal input number 
Powershell :: Take ownership of a folder 
Clojure :: hello world in clojure 
Assembly :: pickle dump into specific directory 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =