• CoRoutine to get async return value?
    0 replies, posted
Hello. I'm not sure if I need a coroutine or what, but I'm trying to return the value of an asynchronous function. The function always returns "nil" because it cannot finish before returning the correct value. Code: function ValidateStream( sURL ) if( !sURL ) then return end local bGood = nil; sound.PlayURL ( sURL, "3d", function( station ) if ( IsValid( station ) ) then station:Stop() bGood = true; else LocalPlayer():ChatPrint( "Invalid URL!" ) end end ) return bGood; end Although "Invalid URL!" doesn't print, the function always returns nil. Is there anyway around this? I remember someone using coroutines to circumvent this before, but I can't really figure out how they work in my context. Any help is appreciated, Thanks
Sorry, you need to Log In to post a reply to this thread.