fix(imports/scaleform): return scaleform handle (#188)

This commit is contained in:
ANTOND
2022-12-30 11:12:03 +01:00
committed by GitHub
parent c40a828465
commit e59089573a

View File

@@ -1,22 +1,22 @@
---Load a scaleform movie. When called from a thread, it will yield until it has loaded. ---Load a scaleform movie. When called from a thread, it will yield until it has loaded.
---@param scaleformName string ---@param scaleformName string
---@param timeout number? Number of ticks to wait for the scaleform movie to load. Default is 500. ---@param timeout number? Number of ticks to wait for the scaleform movie to load. Default is 500.
---@return string? scaleformName ---@return number? scaleform
function lib.requestScaleformMovie(scaleformName, timeout) function lib.requestScaleformMovie(scaleformName, timeout)
if HasScaleformMovieLoaded(scaleformName) then return scaleformName end
if type(scaleformName) ~= 'string' then if type(scaleformName) ~= 'string' then
error(("expected scaleformName to have type 'string' (received %s)"):format(type(scaleformName))) error(("expected scaleformName to have type 'string' (received %s)"):format(type(scaleformName)))
end end
RequestScaleformMovie(scaleformName) local scaleform = RequestScaleformMovie(scaleformName)
if HasScaleformMovieLoaded(scaleform) then return scaleform end
if coroutine.running() then if coroutine.running() then
timeout = tonumber(timeout) or 500 timeout = tonumber(timeout) or 500
for _ = 1, timeout do for _ = 1, timeout do
if HasScaleformMovieLoaded(scaleformName) then if HasScaleformMovieLoaded(scaleform) then
return scaleformName return scaleform
end end
Wait(0) Wait(0)
@@ -25,7 +25,7 @@ function lib.requestScaleformMovie(scaleformName, timeout)
print(("failed to load scaleformName '%s' after %s ticks"):format(scaleformName, timeout)) print(("failed to load scaleformName '%s' after %s ticks"):format(scaleformName, timeout))
end end
return scaleformName return scaleform
end end
return lib.requestScaleformMovie return lib.requestScaleformMovie