The more I work with my game level, the more I wish I could play and stop arbitrary sounds rather than have to specify an entity's Sound0 or Sound1. One great example of use is simply to play a series of random ambient environment sounds such as birds and insects. So we might just have something like the following:
function entity_init(e)
-- pre-load sound for use later on
LoadSound(e, "mysound.wav");
end
function entity_main(e)
if somecondition then
PlaySound(e, "mysound.wav");
else
StopSound(e, "mysound.wav");
end
end
By adding the entity's id to the function call, you can map playing that particular sound on a per entity basis so that multiple instances of the sound can play and you don't interfere with another entity's sounds that are playing. Of course this is just a quick and dirty idea of the implementation, but you get the idea.
System Specs: OS - Windows 7 Home Premium 64-bit SP1, CPU - AMD Phenom II X4 945, 3.0Ghz, RAM - 8Gb DDR3, GFX Card - 2048MB NVIDIA GeForce GT 640, FPSC-R Version - Beta 1.007