infinate loop in lua code example

Example 1: infinite loop lua

-- We need to create a wait function to slow down the while true do loop.
-- The loop will run so fast, that we need to slow it down. Otherwise, it'll crash.

function wait(seconds)
  local start = os.time() 
  repeat until os.time() > start + seconds
end

while true do -- Create the infinite loop
	print("Hello World")
   	
    wait(1) -- The number you place in the paramater is how many seconds it will wait until looping again.
end

Example 2: loop in lua

-- a loop will repeat the code for a limited amount of time
-- let make one
for a = 1 --(from where you want it to start),10 --(how long you want it to be),1 --[How many jumps it needs to make(ex 2, 4, 6, 8,10)]
	print(a) -- now it will count to 10
end

Tags:

C Example