Jump to content

help on a simple enable/disable checker script


kane4355

Recommended Posts

ok so the script compiled and worked but for some reason when tested in game, it didint work until the second activation of the lever before it did the switch. during each state switchover, it faded in and out but worked perfectly fine. Also, the sound that i applied did a continuous loop and did not end. i just attached a random puzzleload sound and it just did a continuous loop. it might just be the audio i used and i will check that out. I also tried attaching an FX to the lever by parent activation on the FX and selecting parent activation only. So that when you activate the lever, it seems as if the power of the bridge being drawn causes dust and debris around the area. i know i can do this through script but all i could see was stuff dealing with the animation as well. anyway just to activate the FX on activation?
Link to comment
Share on other sites

I think the reason the sound loops is because it is set to loop, but obviously I can't tell since I don't know which sound you're using. You could try using StopInstance in order to stop the looping if you don't want to create a new sound that doesn't loop.

 

As for the FX, I don't know why you want to script it if it already works by setting the parent activation.

Link to comment
Share on other sites

I think the reason the sound loops is because it is set to loop, but obviously I can't tell since I don't know which sound you're using. You could try using StopInstance in order to stop the looping if you don't want to create a new sound that doesn't loop.

 

As for the FX, I don't know why you want to script it if it already works by setting the parent activation.

 

DRSRuinsPuzzleOpenLPM was the sound i was using.. it was just something i through in. i would like to add a different sound for either toggle... for a drawbridge im at a struggle as to what to pick for "open" and "close".

 

I havent tested the FX in game, i was just asking to see if it would be more stable scripting versus parent activation. i will check to see if it even works, im using FXdustDropTriggerACT for the FX.

Link to comment
Share on other sites

I think the reason the sound loops is because it is set to loop, but obviously I can't tell since I don't know which sound you're using. You could try using StopInstance in order to stop the looping if you don't want to create a new sound that doesn't loop.

 

As for the FX, I don't know why you want to script it if it already works by setting the parent activation.

 

question on the stop instance parameters: i am having trouble understanding what the instanceID is. the link u sent me says it is: "The instance ID of the sound to stop". is that the sound ID i want or is it just a reference description for "myLoopingSFX" which im assuming would be defined in Sound property....

 

Sound Property bridgesound Auto

Function StopInstance(int aiInstanceID) native global

 

int instanceID = bridgesound.play(self)

Wait(10.0)

Sound.StopInstance(instanceID)

 

 

sorry im a noob with papyrus and learning slowly.....is the above correct or do i need to define the instanceID?

Link to comment
Share on other sites

You don't define the "StopInstance" function in your script:

 

Sound Property bridgesound Auto

;begin event or function
int instanceID = bridgesound.play(self)
Utility.Wait(10.0)
Sound.StopInstance(instanceID)
;end event or function

 

Actually, why do you even need to play the sound? Activators allow you to set their activate sound. Just double click your activator in the object window and select what sound you want.

Link to comment
Share on other sites

Sorry guys, but arn't you over complicating this?

 

You could achieve this by making the Bridge2 section the enable parent (opposite) of the Bridge1 sections and then attach the script defaultActivateToggleLinkedRef to the activating lever and linking the lever to the Bridge2 section.

 

This wouldn't cover the sound part but you could create a customised version of the script and add the appropriate PlaySound statement for the enable/disable parts.

 

For reference this is the pre-existing script

scriptName defaultActivateToggleLinkedRef extends ObjectReference
{
- Toggles the state of the linked ref when this object is activated.
}

ObjectReference myLinkedRef

bool property fade = False Auto

Event OnActivate(ObjectReference triggerRef)
myLinkedRef = GetLinkedRef() as ObjectReference
if (myLinkedRef.IsEnabled())
	myLinkedRef.Disable(fade)
Else
	myLinkedRef.Enable(fade)
EndIf
EndEvent

Link to comment
Share on other sites

DRSRuinsPuzzleOpenLPM was the sound i was using.. it was just something i through in. i would like to add a different sound for either toggle... for a drawbridge im at a struggle as to what to pick for "open" and "close".

 

Any sound file with "LP" or "LPM", etc, at the end is a looping sound. Choose a sound that doesn't end with this. Alternatively you could duplicate this Sound Descriptor form and untick the "loop" option box, then create a new Sound Marker pointing to your duplicated Sound Descriptor form, then use the new Sound Marker either via the property in the script, or in the sound option in the drawbridge Activator form. flobabob's suggestion is very sound (pun intended), you could use his method and add the sound effect to the Activator like fg109 suggested.

Edited by steve40
Link to comment
Share on other sites

Both methods actually work! and the reason i want the sound in the script now is i can manipulate how long it loops which actually sounds great in game utilizing the sound file i said earlier. there is a bit if a problem though with both: because the instance was created and the wait for 10 seconds, the fade of the static objects does not happen until after the sound loop finishes. is this due to order in the scripting? also is there a way to set the time it takes for the fade of objects, per-say, adjust it to take the same amount of time the sound does? IE 10 seconds to fade in versus instantly fading in? I also fixed the issue with having to activate the lever twice for the drawbridge script, it now does what it is supposed to do on one activate.

 

here are the two scripts:

 

Scriptname DKDrawbridgescript extends ObjectReference

 

ObjectReference Property bridge1a Auto

ObjectReference Property bridge1b Auto

ObjectReference Property bridge1c Auto

ObjectReference Property bridge1d Auto

ObjectReference Property bridge1e Auto

ObjectReference Property bridge2 Auto

Sound Property bridgesound Auto

 

;Thanks Cipscis - http://www.cipscis.c...als/states.aspx

Auto State Off

Event OnActivate(ObjectReference akActionRef)

GoToState("On")

;begin event or function

int instanceID = bridgesound.play(self)

Utility.Wait(3.0)

Sound.StopInstance(instanceID)

;end event or function

bridge1a.Enable()

bridge1b.Enable()

bridge1c.Enable()

bridge1d.Enable()

bridge1e.Enable()

bridge2.Disable()

EndEvent

EndState

 

State On

Event OnActivate(ObjectReference akActionRef)

GoToState("Off")

;begin event or function

int instanceID = bridgesound.play(self)

Utility.Wait(3.0)

Sound.StopInstance(instanceID)

;end event or function

bridge1a.Disable()

bridge1b.Disable()

bridge1c.Disable()

bridge1d.Disable()

bridge1e.Disable()

bridge2.Enable()

EndEvent

EndState

 

 

scriptName DKActivateToggleLinkedRef extends ObjectReference

{

- Toggles the state of the linked ref when this object is activated.

}

 

ObjectReference myLinkedRef

Sound Property bridgesound Auto

 

 

bool property fade = False Auto

 

Event OnActivate(ObjectReference triggerRef)

;begin event or function

int instanceID = bridgesound.play(self)

Utility.Wait(10.0)

Sound.StopInstance(instanceID)

;end event or function

myLinkedRef = GetLinkedRef() as ObjectReference

if (myLinkedRef.IsEnabled())

myLinkedRef.Disable(fade)

Else

myLinkedRef.Enable(fade)

EndIf

EndEvent

 

thank you guys for all your help! this is a lot easier for me then creating an animation (which i have no experience at all with 3d modeling).

Link to comment
Share on other sites

Here's a modified version of fg109's script

 

 

 

Scriptname DKDrawbridgescript extends ObjectReference 

ObjectReference Property bridge1a Auto 
ObjectReference Property bridge1b Auto 
ObjectReference Property bridge1c Auto 
ObjectReference Property bridge1d Auto 
ObjectReference Property bridge1e Auto 
ObjectReference Property bridge2 Auto 
Sound Property bridgesound Auto 

;Thanks Cipscis - http://www.cipscis.c...als/states.aspx 
Auto State On 
       Event OnActivate(ObjectReference akActionRef) 
               GoToState("Off") 
        int instanceID = bridgesound.play(self) 
               bridge1a.Disable() 
               bridge1b.Disable() 
               bridge1c.Disable() 
               bridge1d.Disable() 
               bridge1e.Disable() 
               bridge2.Enable() 
        Utility.Wait(3.0)  ; adjust this duration to your taste
        Sound.StopInstance(instanceID)
        EndEvent 
EndState 

State Off 
       Event OnActivate(ObjectReference akActionRef) 
               GoToState("On") 
        int instanceID = bridgesound.play(self)
               bridge1a.Enable() 
               bridge1b.Enable() 
               bridge1c.Enable() 
               bridge1d.Enable() 
               bridge1e.Enable() 
               bridge2.Disable() 
        Utility.Wait(3.0) ; adjust this duration to your taste
        Sound.StopInstance(instanceID)
       EndEvent 
EndState

 

Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

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