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

@@ -11,21 +11,11 @@ function lib.requestNamedPtfxAsset(ptFxName, timeout)
RequestNamedPtfxAsset(ptFxName)
if coroutine.isyieldable() then
timeout = tonumber(timeout) or 500
if not coroutine.isyieldable() then return ptFxName end
for _ = 1, timeout do
if HasNamedPtfxAssetLoaded(ptFxName) then
return ptFxName
end
Wait(0)
end
print(("failed to load ptFxName '%s' after %s ticks"):format(ptFxName, timeout))
end
return ptFxName
return lib.waitFor(function()
if HasNamedPtfxAssetLoaded(ptFxName) then return ptFxName end
end, ("failed to load ptFxName '%s'"):format(ptFxName), timeout or 500)
end
return lib.requestNamedPtfxAsset