play_sound(...) - is there any 'rate limit' to the API?
Posted: Tue Oct 07, 2025 2:00 am
Hi,
I have a mod that (conditionally) uses luaForce.play_sound(...) in a on_entity_died event handler. Despite my best efforts and tracing through with a debugger, I'm finding that the sound does not reliably play despite the function call for sure executing.
Is there any circumstance where play_sound will ignore the call? Maybe some global rate limit per tick or per event callback, or something like that?
My guess is I've just done something dumb in my code. But I'm kinda at a loss so just double-checking expectations. I seem to get more consistent results calling play_sound when I 'defer' the calls to be executed later (e.g. in an on_tick() callback). That's why I'm asking about rate limits.
I DO know about the sound definitions having (configurable) limits on concurrency. But in this case no other "copy" of this particular custom sound file is playing, yet nothing plays.
I have a mod that (conditionally) uses luaForce.play_sound(...) in a on_entity_died event handler. Despite my best efforts and tracing through with a debugger, I'm finding that the sound does not reliably play despite the function call for sure executing.
Is there any circumstance where play_sound will ignore the call? Maybe some global rate limit per tick or per event callback, or something like that?
My guess is I've just done something dumb in my code. But I'm kinda at a loss so just double-checking expectations. I seem to get more consistent results calling play_sound when I 'defer' the calls to be executed later (e.g. in an on_tick() callback). That's why I'm asking about rate limits.
I DO know about the sound definitions having (configurable) limits on concurrency. But in this case no other "copy" of this particular custom sound file is playing, yet nothing plays.