Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Win/Lose Detection, help?

Asked by
Turgon 80
10 years ago

Im trying to make a game that loops rounds (like Deathrun, Murder, etc).. The looping works well but i need an efficient way to detect win/lose situations.. It runs the game function to check if it returns a lose or a win.. And the timer is inside the game function and it checks if the goal part has been touched every second. If it doesnt get touched and players run out of time, the game restarts.. I couldn't come up with a way to check if the players are all dead. (I have a table of players that are in the game) This whole system seems pretty horrible to me for some reason. Anyone has a better idea for me to improve it?

1 answer

Log in to vote
0
Answered by 10 years ago

This is what I got, hope it helps

function gamefinished()
    --better to do this outside the loop otherwise it gets done each time, but put this back to its original sate if game_time changes?
    gameTime=game_time-10
    for i=game_time,0,-1 do

        if i<=game_time and i>=gameTime then
            msg.Value = "The door will open in " .. (i - gameTime)
        else
            msg.Value = "Time left: " .. i
        end

        wait(1)

        --there is no faster way to do this becouse lua lack a switch or case function :(
        if gameend then
            return "win"
        elseif i == 0 then
            return "timout"
        elseif #igplyrs == 0 then
            return "fail"
        end

        gaim = gamefinish()     

        if gaim == "win" then
            msg.Value = "The players made it out alive!"
            wait(3)
        elseif gaim == "fail" then
            msg.Value = "The players lost!"
            wait(3)
        elseif gaim == "timout" then
            msg.Value = "The players ran out of time!"
            wait(3)
        end 

    end
end
0
http://pastebin.com/gPWeaw0G Here's a part of the script Turgon 80 — 10y
0
Thanks but not exactly what i was looking for. The problem is that, i have a table of players (the players that are playing in the round, NOT the players in game.). I can check every seconds how many players there are in the round but i cant find a way to remove them from the table when they die.. Instead of trying to fix that, i wanted to change the whole system to make it more efficient. Turgon 80 — 10y
0
You need a propety to store all of the players who are playing the game. Once the player had dies or resporns remove them from the table, once every entity in the table is nill or "" (however you want to store the killed players) stop the game User#5423 17 — 10y
Ad

Answer this question