Re: Play a fixed sound when weapon stops firing.
Currently, the most practical way to use Lua to play a sound is to spawn an AEmitter at the location where you want the sound to be played, and the AEmitter's BurstSound is the sound (for when you want single instances of sounds to be played, could using EmissionSound for looping sounds).
Example of code for that is the first chunk in Base.rte/Devices/Explosives/Remote Explosives.ini
To play different sounds based on how long you've held the trigger, could use a timer to keep track of how long the trigger was held and spawn different sounds based on that.
http://wiki.datarealms.com/LuaDocs/HeldDeviceI believe IsActivated() is used to check if a gun is being fired. You can also look in Dummy.rte/Devices/Weapons/Annihiliator.lua for an example of checking when the gun is being fired, and playing an effect based on how long the trigger was held.