How to make an infinite loop in Lua code?

36,162

Solution 1

You want a while loop:

while true do
  proxy:PlayerParamRecover()
  proxy:PlayerRecover()
  proxy:EnableInvincible(10000,true)
end

Additional information here

Note that, since the while loop will always have control of the program after entering that loop, any code you write after it won't ever execute. Infinite loops are only useful in extreme cases - make sure that what you want to do warrants it.

Solution 2

There are two ways to use infinite loop:

repeat
-- do something
until false

-- or --

while true do
-- do something
end
Share:
36,162
Mark
Author by

Mark

Updated on July 09, 2022

Comments

  • Mark
    Mark almost 2 years

    I have three local functions that I want to use forever in memory:

    proxy:PlayerParamRecover();
    proxy:PlayerRecover();
    proxy:EnableInvincible(10000,true);
    

    I'm not sure how to add them in an infinite loop.