pcaviator Posted April 23, 2019 Share Posted April 23, 2019 I've made a custom sound effect. When I place it into a world space (Tamriel-WhiterunExterior01) it plays OK. I want to have the SFX play (loop) when the player enters a trigger box located in that world-space, & stop playing (looping) when the player leaves the trigger box area. The script for this is below, but I can't get it to compile either inside the CK or inside Notepad++. In CK, I open the triggerbox properties & go to the 'script' tab. Then "add" to add a new script, BUT I get a "the extends script does not exist, pick one that does". I've copied the scripts.rar file from Oldrim & extracted it to ./scripts/source folder. I can't figure out why CK won't let me enter the script directly? Is there a better way to have a SFX play when the player get close to an object? scriptname _AST_FjotoitWellWaterSFX extends ObjectReference ; _AST_FjotoitWellSFX ObjectReference Property _AST_FjotoitWellTRIG Auto Event OnTriggerEnter(ObjectReference akActionRef) if akActionRef == Game.GetPlayer() _AST_FjotoitWellSFX.Enable debug.notification("Player Entered Well Trigger") endif Endevent Event OnTriggerLeave(ObjectReference akTriggerRef) if akActionRef == Game.GetPlayer() _AST_FjotoitWellSFX.Disable debug.notification("Player Left Well Trigger") endif endevent Link to comment Share on other sites More sharing options...
Ghaunadaur Posted April 23, 2019 Share Posted April 23, 2019 If this is for SSE, the source files need to be in Data\source\scripts. As soon you fixed that, change your script to something like this, assuming it's attached to the trigger box: Scriptname _AST_FjotoitWellWaterSFX extends ObjectReference Sound Property _AST_FjotoitWellSFX auto int SoundInstanceID Event OnTriggerEnter(ObjectReference akActionRef) if akActionRef == Game.GetPlayer() if Is3dLoaded() SoundInstanceID = _AST_FjotoitWellSFX.Play(self) endif debug.notification("Player Entered Well Trigger") endif EndEvent Event OnTriggerLeave(ObjectReference akActionRef) if akActionRef == Game.GetPlayer() if SoundInstanceID Sound.StopInstance(SoundInstanceID) endif debug.notification("Player Left Well Trigger") endif EndEvent In this example, the source of the sound will be the trigger box (self). Link to comment Share on other sites More sharing options...
pcaviator Posted April 24, 2019 Author Share Posted April 24, 2019 (edited) Thankyou very much for your assistance Ghaunadaur. I've managed to compile the script without errors & attach it to the trigger box, but there is no sound output when the player enters the trigger box. I slightly altered the script code to better detect where to problem lies. I see the "player enters" debug message when the player enters the triggerbox, but I don't see the debug message saying the player exited the triggerbox. This suggests that the SoundInstanceID variable is not being set & thus there seems to be a problem with how I've set up my sound file in CK. I created a new 'sound descriptor' & pointed it to the soundFx WAV file. The WAV file does not 'audition' in the sound descriptor dialog but I believe this is a known CK issue. The sound file is uncompressed (PCM audio format) 44100Hz 1411 kb/s 2 channels. Do you know where I've got the sound setup wrong? Scriptname _AST_FjotoitWellWaterSFX extends ObjectReference ; _AST_WaterDripsLargeRever setup as a 'sound descriptor' type Sound Property _AST_WaterDripsLargeReverb auto int SoundInstanceID Event OnTriggerEnter(ObjectReference akActionRef) if akActionRef == Game.GetPlayer() if Is3dLoaded() SoundInstanceID = _AST_WaterDripsLargeReverb.Play(self) debug.notification("Player Entered Well Trigger") endif endif EndEvent Event OnTriggerLeave(ObjectReference akActionRef) if akActionRef == Game.GetPlayer() if SoundInstanceID Sound.StopInstance(SoundInstanceID) debug.notification("Player Left Well Trigger") endif endif EndEvent Edited April 24, 2019 by pcaviator Link to comment Share on other sites More sharing options...
Ghaunadaur Posted April 24, 2019 Share Posted April 24, 2019 I tested it with a random looping sound, and it started to play when entering the trigger and stopped when leaving just as intended. So I guess there's something wrong either with the way the sound descriptor is set up, or with the sound file itself. I'm not really an expert at sound editing, but maybe this article could be of help.Also, double check that the property is filled with the correct sound marker. For debugging you can also print out the Instance ID, if it's 0 then something went wrong. debug.notification("Player Entered Well Trigger, "+SoundInstanceID) Link to comment Share on other sites More sharing options...
Recommended Posts