Passing params with audio onComplete

I am trying to get the caller of a function from audio onComplete. I have tried operating on the values coming from the event but I am not having any luck.

  
audio.play(soundList[sound].clip, {loops = sLoops, onComplete=multipleSoundDec});  
  
...  
  
function multipleSoundDec(e)  
 for key,value in pairs(e) do  
 print( key, value )  
 end  
 -- What audio clip called me?  
  
end  
  

I thought using e.handle would get me the data but every time I try to access anything about it I get “attempt to index field ‘handle’ (a userdata value)”

I have also tried

audio.play(soundList[sound].clip, {loops = sLoops, onComplete=function() print("clip: ", self) end});  

and that does not work either. Any ideas? [import]uid: 70996 topic_id: 19547 reply_id: 319547[/import]

Use a closure to call another function and pass params.

Example:

 local audioclosure = function() return multipleSound( sound ) end  
  
audio.play(soundList[sound].clip, {loops = sLoops, onComplete=audioclosure})  
  
function multipleSound(var) ...  
   

EDITED: new code to retunr function closure [import]uid: 55808 topic_id: 19547 reply_id: 75472[/import]

Wow, thank you very much.

I never would have thought of that. I have a long way to go regarding “thinking in Lua”.

Again, thanks for the help and the quick reply. [import]uid: 70996 topic_id: 19547 reply_id: 75475[/import]