Hi all.
So the title says what i’m trying to do, make timers that are player specific, and running in parallel for everyone, but I find it to be quite a bit of a confusing topic…
The idea is, when the global timer gets to a specific point in round-making loop, everyone is assigned a different zone, and there different timers for each zone, which is why they’d be required to run in parallel, because it would pretty much be different for everyone.
I have a contestants table, and my idea was run an in pairs loop through it and call a function, that handles the teleportation and timer, but the thing is, there would be many cycles (as many as players), so my idea was, when that timer ends, call the same function again, for the second cycle, which, again, would be different for everyone.
So I realized there’s no way I would be able to do this without coroutines… problem is… I’m not so sure where and how would I use them, and yes, I’m aware that it wouldn’t truly be parallel, I at least need the illusion of…
Would I have to have a coroutine version of the function that assigns it, and have a table of connections, each time I call it, as in:
local corutine_function = coroutine.wrap(function(player)
-- timer stuff
local message = coroutine_function(player)
end)
for i,player in pairs(contestants) do
local message = coroutine_function(player)
end
… or something like that?
I have a plan B for this system in my game, but I’d prefer to do the timers parallel and player specific…