Jump to content

Please help...trying to script a secret wall door


River65

Recommended Posts

If the 'Sound FX' is not a looping sfx then the script should be as follow:



Sound Property SFX Auto

Bool Property Triggered = False Auto Hidden


Auto State WaitingActivation
Event OnActivate (ObjectReference akActionRef)
If ( Triggered == False )
GoToState("Busy")
Triggered = True
SFX.Play(Self)
PlayGamebryoAnimation("Forward", True)
Utility.Wait(4.33)
GoToState("WaitingActivation")
Else
GoToState("Busy")
Triggered = False
SFX.Play(Self)
PlayGamebryoAnimation("Backward", True)
Utility.Wait(4.33)
GoToState("WaitingActivation")
EndIf
EndEvent
EndState


State Busy
;
EndState



* You don't add a sound marker to your cell, but you choose the sound from the script's property.



If it is a 'Looping' sound then use the same script (the first one) but replace this line:

StopInstance(SoundInstance)

with this one:

Sound.StopInstance(SoundInstance)


* Sorry about that... i wrote the script in a hurry.



Have a pleasant day.

Edited by maxarturo
Link to comment
Share on other sites

 

If the 'Sound FX' is not a looping sfx then the script should be as follow:

Sound Property SFX Auto
 
Bool Property Triggered = False Auto Hidden
 
 
Auto State WaitingActivation
Event OnActivate (ObjectReference akActionRef)
      If ( Triggered == False )
            GoToState("Busy")
            Triggered = True
            SFX.Play(Self)
            PlayGamebryoAnimation("Forward", True)
            Utility.Wait(4.33)
            StopInstance(SoundInstance)
            GoToState("WaitingActivation")
   Else
            GoToState("Busy")
            Triggered = False
            SFX.Play(Self)
            PlayGamebryoAnimation("Backward", True)
            Utility.Wait(4.33)
            StopInstance(SoundInstance)
            GoToState("WaitingActivation")
 EndIf
EndEvent
EndState
 
 
State Busy
         ;
EndState

* You don't add a sound marker to your cell, but you choose the sound from the script's property.
If it is a 'Looping' sound then use the same script (the first one) but replace this line:
StopInstance(SoundInstance)
with this one:
Sound.StopInstance(SoundInstance)
* Sorry about that... i wrote the script in a hurry.
Have a pleasant day.

 

Thank you for taking the time to write this for me. The sound is attached to the script's property, it's one of the secret wall open sounds, so it doesn't loop.

 

I'm still having issues with it compiling when I add StopInstance(SoundInstance) which I'm assuming (SoundInstance) would be (SFX.Play(Self)). I get an error stating that it's not a function....

But when I changed it to - Sound.StopInstance(SFX.Play(Self)) it compiled, even though it's not a looping sound.

 

So the script is now as follows:

 

Scriptname R65SecretWallDoor extends ObjectReference

{Plays Gamebryo based animation with sound.}

 

Sound Property SFX Auto

 

Bool Property Triggered = False Auto Hidden

 

 

Auto State WaitingActivation

Event OnActivate (ObjectReference akActionRef)

If ( Triggered == False )

GoToState("Busy")

Triggered = True

SFX.Play(Self)

PlayGamebryoAnimation("Forward", True)

Utility.Wait(4.33)

Sound.StopInstance(SFX.Play(Self))

GoToState("WaitingActivation")

Else

GoToState("Busy")

Triggered = False

SFX.Play(Self)

PlayGamebryoAnimation("Backward", True)

Utility.Wait(4.33)

Sound.StopInstance(SFX.Play(Self))

GoToState("WaitingActivation")

EndIf

EndEvent

EndState

 

 

State Busy

;

EndState

 

 

I couldn't have done this without your help - again Thank-you Maxarturo.

Edited by River65
Link to comment
Share on other sites

From the script you posted (above), remove this line:

Sound.StopInstance(SoundInstance)


or just use the last script i posted, which has been rectify, i remove the "Sound.StopInstance(SoundInstance)", it's not needed.

And again sorry..., i'm having some trouble the last 2 days and i can't concentrate, too much work and too tired...

Edited by maxarturo
Link to comment
Share on other sites

It didn't compile the first time because it was a syntax error. StopInstance() is expecting a value, not name and Sound.Play() returns the instanceID(as an integer) of that sound, that's why it compiled because that was the correct passing into the argument.

Edited by Rasikko
Link to comment
Share on other sites

 

From the script you posted (above), remove this line:
Sound.StopInstance(SFX.Play(Self))
or just use the last script i posted, which has been rectify, i remove the "Sound.StopInstance(SFX.Play(Self))", it's not needed.
And again sorry..., i'm having some trouble the last 2 days and i can't concentrate, too much work and too tired...

 

Thank-you - I hope you get a decent nights sleep.

 

 

It didn't compile the first time because it was a syntax error. StopInstance() is expecting a value, not name and Sound.Play() returns the instanceID(as an integer) of that sound, that's why it compiled because that was the correct passing into the argument.

Hi Rasikko, thank you for responding. So sound.play() is the value that StopInstance() is expecting? (trying to wrap my head around this...as an integer of that sound) I can sort of grasp the logic, but the terminology is confusing. I've been watching a series I found on tesalliance about understanding papyrus, but I had to take a break.

 

And since the sound is not a looping sound, it will automatically stop on it's own and I don't need to state the StopInstance() function in the script? Did I get that right?

Link to comment
Share on other sites

In the terms for one not familiar with papyrus lingo, integer = number that isn't a floating point value(a percentage to keep it simple)

 

You can do either of the following:

 

int iSoundInstance = mySound.Play(self)

; store the number/id of this sound playing

 

StopInstance(iSoundInstance)

 

-or-

 

StopInstance(mySound.Play(self))

 

 

Since sound.Play() returns a number of the sound being played.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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