1
Modding / Re: Misc modding questions that are too minor to warrant their own thread
« on: May 27, 2021, 11:07:48 AM »Doesn't seem like the sound player API has a way to do that.
Mega gross workaround I thought of: Break up the sound into chunks (say 0.5 seconds each).
In the weapon script, at each interval, check if we should continue playing the overall sound effect. If yes, play the next sound in the sequence, if not, reset and leave.
Hmm - I think SoundAPI.stop() should do it? And the various playSound() methods return a SoundAPI.
I'm not sure you understand - starting a sound or playing it isn't the real issue - making the sound loop naturally is.
Basically, within an EveryFrame scrip, and within the main fire squence (powerup and powerdown work) I have to know when the sound finished playing to start playing it again, for as long as the weapon is fireing.
The weapon itself can fire for 10 seconds (or less, depending on flux level). Since it's a builtin weapon, I COULD just remove any ties to flux and make it so it will ALWAYS fire for 10 seconds, but I don't like that solution.
I could also edit the fire sound ot be exactly 10 second long and only play it once, but again...seems like a bad solution.
If a looping sound is what you're after, you should look intoCodeand its overloads. These all allows a looping sound to be played on command, and you can change their properties such as pitch and volume as they loop. Needs to be called once per frame to keep the loop going, but otherwise it sounds like exactly what you're looking for.Global.getSoundPlayer().playLoop()
So I need to replace this: Global.getSoundPlayer().playSound("vns_Reflex_fire", 1f, 1f, point, ZERO);
with the below?
void playLoop(java.lang.String id, java.lang.Object playingEntity, float pitch, float volume, Vector2f loc, Vector2f vel)
What would be a playingEntity? I'm not sure what goes there.
The playingEntity would be your weapon or ship (don't remember, someone correct me here); it's used so that two of the same "source" with a looping sound doesn't result in two different sounds.