Loops 如何在Lua代码中生成无限循环?

Loops 如何在Lua代码中生成无限循环?,loops,lua,infinite-loop,Loops,Lua,Infinite Loop,我想在内存中永远使用三个本地函数: proxy:PlayerParamRecover(); proxy:PlayerRecover(); proxy:EnableInvincible(10000,true); 我不知道如何将它们添加到无限循环中。您需要而循环: while true do proxy:PlayerParamRecover() proxy:PlayerRecover() proxy:EnableInvincible(10000,true) end 补充资料 请注意,

我想在内存中永远使用三个本地函数:

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

我不知道如何将它们添加到无限循环中。

您需要
循环:

while true do
  proxy:PlayerParamRecover()
  proxy:PlayerRecover()
  proxy:EnableInvincible(10000,true)
end
补充资料


请注意,由于while循环在进入该循环后将始终控制程序,因此在它之后编写的任何代码都不会执行。无限循环仅在极端情况下有用-请确保您想做的事情保证了这一点。

使用无限循环有两种方法:

repeat
-- do something
until false
--或--

如果您想在命令栏中每秒、无限或类似地说“Hello”,您可以使用以下格式:

    while true do
    -- whatever
    end
比如说,

    while true do
    print("Hello")
    wait(1)
    end

“永远在记忆中使用”是什么意思?请注意,该语言的名称为“Lua”,而不是“Lua”。这是地球卫星的专有名称,葡萄牙语。如果你想编辑你的问题,你可以点击标签下面的“编辑”链接。试一试。你在哪个游戏引擎或环境中工作?这可能对你的问题很重要一件事:你不能在“do”之后写冒号,这是你在Python中会做的,但在LuaAlso中不会,即使在同一行上有多个语句,Lua中也不需要分号,而且不太可能是解决个人问题的正确方法
    while true do
    print("Hello")
    wait(1)
    end