Loops 如何使lua在while-true循环中停止if循环?

Loops 如何使lua在while-true循环中停止if循环?,loops,if-statement,lua,logic,roblox,Loops,If Statement,Lua,Logic,Roblox,这是一个很难问的问题,因为我不可能把所有的东西都放在一个问题里,但我可以解释这个问题。我的游戏逻辑/游戏脚本基本上是: function game() -- stuff end while true do while players < 2 do -- tell player to invite more players and all that jazz end if players >= 2 then game() en

这是一个很难问的问题,因为我不可能把所有的东西都放在一个问题里,但我可以解释这个问题。我的游戏逻辑/游戏脚本基本上是:

function game()
-- stuff
end

while true do
    while players < 2 do
     -- tell player to invite more players and all that jazz
    end

    if players >= 2 then
       game()
    end
end

问题在于,由于“game()”一直在运行,玩家会不断地移动到游戏所在的位置(使他们无法移动)。在所有球员都被移动后,我如何让Lua停止移动球员?我尝试使用for循环,但由于“game()”正在重复,因此也不断重复。我希望任何熟悉Lua的人都能理解这一点。

在我看来,您希望维护两个列表:当前正在播放和希望播放


我不确定你的逻辑到底是什么(人们可以加入正在进行的游戏吗?),但基本的想法是你只在希望玩的玩家列表中运行游戏,而不是在当前玩的玩家列表中运行游戏。

你能在
游戏()之后打破
循环吗
call?@itdoesn如果我使用break,则只移动1名玩家。然后在移动玩家时标记他们,并且只移动未标记的玩家?
if #ready >= 2 then -- if the players in the list 'ready' (the players that are ready to start the game) 
    print(player.Name .. " moved") -- show which player is moved
    player:MoveTo(--place where the game is)) -- actually move the player
end