Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an infinite loop in Lua code?

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.

like image 765
Mark Avatar asked Dec 09 '22 12:12

Mark


2 Answers

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.

like image 81
Dave McClelland Avatar answered Dec 30 '22 16:12

Dave McClelland


There are two ways to use infinite loop:

repeat
-- do something
until false

-- or --

while true do
-- do something
end
like image 45
R. Gadeev Avatar answered Dec 30 '22 15:12

R. Gadeev