Is there any way to define self in a table function so I don’t have to declare an empty variable to put the function in early? In my case:
local ragDollTimer_rount
ragDollTimer_rount = globalfunc.coroutine.create(function()
while true do
if ragDollTimer.Value > 0 then
ragDollTimer.Value = ragDollTimer.Value - 10
wait(.1)
else
if canRecover.Value then
ragDollValue.Value = false
end
ragDollTimer_rount:yield()
end
end
end)
Goal
local ragDollTimer_rount = globalfunc.coroutine.create(function()
while true do
if ragDollTimer.Value > 0 then
ragDollTimer.Value = ragDollTimer.Value - 10
wait(.1)
else
if canRecover.Value then
ragDollValue.Value = false
end
self:yield()
end
end
end)
In my case, I need to check if the coroutine is running or not, and coroutine.running() just returns the thread from which it runs on. Coroutine.status will not work, since it always returns suspended in my case. Here I just have a module function that creates a table that contains the coroutine and a boolean that determines if it runs for not. Yielding within that module makes the bool false, and resuming it within the module makes the bool true.