Search
 
SCRIPT & CODE EXAMPLE
 

LUA

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

do while lua

repeat
	someThing()
	someOtherThing()
until not c
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

while loop in lua

local can_do = true
local countdown = 0.85 --you can choose whatever you want

while can_do do
    --here your code
    wait(countdown)    
Comment

lua loop

while wait() do
Comment

while loop lua

while i < n do
	print(i^2) -- Same here
	i = i+1 --Stick your own here
end
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

open while loop lua

Open while loops can potentially crash your program so be careful!
Comment

PREVIOUS NEXT
Code Example
Lua :: repeat until lua 
Lua :: do while lua 
Lua :: glua varargs 
Lua :: roblox luau random number 
Lua :: lua get time 
Lua :: lua game code 
Lua :: lua print 
Lua :: lua for loops 
Lua :: how to split strings into 2 string by space lua 
Lua :: What is CanCollide in roblox? 
Lua :: lua how to make a click to activate button 
Lua :: roblox add attribute 
Lua :: how to format a number into hh:mm:ss in lua 
Lua :: roblox create part script 
Lua :: how to make a math text in lua 
Lua :: open while loop lua 
Matlab :: matlab inverse z transform 
Matlab :: matlab preallocate array size 
Matlab :: alternative from two vectors matlab 
Basic :: how to open d drive using conda prompt 
Basic :: c++ code to c code converter 
Elixir :: elixir string concatination 
Elixir :: elixir mapset member 
Scala :: two dimensional array scala 
Scala :: scala named function 
Actionscript :: dig WWW.EXAMPLE.COM +nostats +nocomments +nocmd 
Excel :: excel and 
Perl :: perl mechanize infinite scroll 
Pascal :: comment in pascal 
Gdscript :: godot ignore function 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =