Jump to content

Script that plays a created sound descriptor on loop?


Recommended Posts

Basic backstory, new to scripting. Not quite sure how to aptly title this.

I'm looking for a way to have a crafting station repeatedly play a sound descriptor every so often with the use of a script. 

The end product I'm hoping to achieve is a Crafting Station that will idly play a sound descriptor, wait between 5-10 minutes, and play a sound descriptor again. All of that without having to interact with the crafting station in the first place.

If I must have it be done via interaction, that is okay. The main thing I want is the repeated sound descriptor.

I don't want it to play a sound descriptor that is looping, as that only seems to play a single audio file and not a random one from the descriptor (unless I got unlucky on the activations).

Currently, I only have a simple script that will play the sound descriptor whenever the item is interacted with. Not exactly what I want, especially since repeated interactions will cause the sound to overlap and destroy my eardrums.

  Reveal hidden contents

I also attached a picture of the Sound Descriptor, if that could help explain things.

As a side note, I would like to know if there's a way I can make it so that proximity to the crafting station plays a sound descriptor, as if bumping into it. This has nothing to do with the above request's script or sound descriptor, it would be completely separate.

JuggernogJingleSoundDescriptor.png

Link to comment
Share on other sites

Something like this should work:

  Reveal hidden contents

Link to comment
Share on other sites

I'd say the timer should be outside of the distance conditional.

Function PlayCustomSound()		; code of the function
	If Game.GetPlayer().GetDistance(Self) <= 1000	; player is within 1000 game units to this reference
		RCA_JuggernogJingle.Play(Self)		; play the sound
	EndIf
	StartTimerGameTime(0.25, 555)			; restart the timer
EndFunction

That way it will continue looping the timer, even if you are more than 1000 units away, until it unloads.

Link to comment
Share on other sites

  On 7/19/2024 at 11:24 AM, DieFeM said:

I'd say the timer should be outside of the distance conditional.

Function PlayCustomSound()		; code of the function
	If Game.GetPlayer().GetDistance(Self) <= 1000	; player is within 1000 game units to this reference
		RCA_JuggernogJingle.Play(Self)		; play the sound
	EndIf
	StartTimerGameTime(0.25, 555)			; restart the timer
EndFunction

That way it will continue looping the timer, even if you are more than 1000 units away, until it unloads.

Expand  

You're right. The distance check was actually an afterthought.

Link to comment
Share on other sites

You should keep the handle you get when starting the sound if you want more fine-grained control over how and for how long it's played. It's an integer that is acquired when calling <sound>.Play(ObjectReference). e.g.: "int instanceID = mySFX.play(self)"
You can then cancel the playback at any point by calling Sound.StopInstance(instanceID). You can also manipulate the volume using the handle. Read more here: 
https://falloutck.uesp.net/wiki/Sound_Script

Link to comment
Share on other sites

Why don't you set the descriptor to loop ?

There's currently no way for a script to get notified when a sound started via Play() has ended. A script can't even check if the sound is still playing rn.
All that will change soon (TM).

Link to comment
Share on other sites

  On 7/20/2024 at 1:35 AM, niston said:

Why don't you set the descriptor to loop ?

There's currently no way for a script to get notified when a sound started via Play() has ended. A script can't even check if the sound is still playing rn.
All that will change soon (TM).

Expand  

The sound descriptor doesn't shuffle between different audio files when it is set to loop, as far as I know. It just picks one on the initial call and sticks with it until it is ended and called again. I would prefer it to shuffle between the audio files randomly.

Link to comment
Share on other sites

Big thanks, everyone! Got it working. I found using a normal timer over a Game Time timer worked better. I hope that doesn't cause any issues that I'm unaware of.

I have attached the script I used for anyone in the future. (Note: I added another sound that plays when the machine loads in for the first time, and added a ~30 second buffer of silence to the repeating sound's .wav files.)

  Reveal hidden contents

Again, huge thanks to everyone involved!

  • Like 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...