feat(imports): lib.waitFor

This commit is contained in:
Linden
2023-07-31 16:06:44 +10:00
parent c6742eeae9
commit f11668b95c
8 changed files with 63 additions and 100 deletions

View File

@@ -9,23 +9,11 @@ function lib.requestScaleformMovie(scaleformName, timeout)
local scaleform = RequestScaleformMovie(scaleformName)
if HasScaleformMovieLoaded(scaleform) then return scaleform end
if not coroutine.isyieldable() then return scaleform end
if coroutine.isyieldable() then
timeout = tonumber(timeout) or 500
for _ = 1, timeout do
if HasScaleformMovieLoaded(scaleform) then
return scaleform
end
Wait(0)
end
print(("failed to load scaleformName '%s' after %s ticks"):format(scaleformName, timeout))
end
return scaleform
return lib.waitFor(function()
if HasScaleformMovieLoaded(scaleform) then return scaleform end
end, ("failed to load scaleform '%s'"):format(scaleform), timeout or 500)
end
return lib.requestScaleformMovie