Jump to content

help on a simple enable/disable checker script


kane4355

Recommended Posts

Here's a modified version of flobabob's script:

 

 

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

ObjectReference myLinkedRef     
bool property fade = False Auto     
Sound Property bridgesound Auto

Event OnActivate(ObjectReference triggerRef)     
       myLinkedRef = GetLinkedRef() as ObjectReference     

int instanceID = bridgesound.play(self)

       if (myLinkedRef.IsEnabled())     
               myLinkedRef.Disable(fade)     
       Else     
               myLinkedRef.Enable(fade)     
       EndIf     

Utility.Wait(3.0) ; change this duration to your taste
Sound.StopInstance(instanceID)
EndEvent

 

 

*** Note that I've changed the script name slightly. You don't really want to modify the default script :tongue:

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.

 

Kane, if you change "disable()" and "enable()" to "disable(true)" and "enable(true)" in your script, then they will fade out a bit more slowly instead of just popping off and on. Unfortunately it is not possible to specify the fade time other than this way. However, if you add the "true" flag as I suggested, the script will wait for each individual drawbridge to fade in, so if each fade takes about 2 seconds then your six drawbridges should take about 12 seconds to finish fading in overall :biggrin:

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.

 

Kane, if you change "disable()" and "enable()" to "disable(true)" and "enable(true)" in your script, then they will fade out a bit more slowly instead of just popping off and on. Unfortunately it is not possible to specify the fade time other than this way. However, if you add the "true" flag as I suggested, the script will wait for each individual drawbridge to fade in, so if each fade takes about 2 seconds then your six drawbridges should take about 12 seconds to finish fading in overall :biggrin:

 

that would work - except i need all of bridge1a-e to fade in at the same time instead of all 5 pieces individually. they connect together making the "bridge" itself. bridge2 is just there to visualize the bridge is closed mode.

Link to comment
Share on other sites

that would work - except i need all of bridge1a-e to fade in at the same time instead of all 5 pieces individually. they connect together making the "bridge" itself. bridge2 is just there to visualize the bridge is closed mode.

 

Ah, I see. Ok, change the code "disable(true)" and "enable(true)" to "DisableNoWait(true)" and "EnableNoWait(true)".

The pieces should all fade simultaneously and will take about 2 seconds to fade instead of "popping".

The script won't wait for the pieces to finish fading, so putting the "wait" function (of about 3-4 seconds) AFTER the enable/disable commands (like in my last 2 script examples) is necessary to give the sound time to play. Cheers.

Link to comment
Share on other sites

that would work - except i need all of bridge1a-e to fade in at the same time instead of all 5 pieces individually. they connect together making the "bridge" itself. bridge2 is just there to visualize the bridge is closed mode.

 

Ah, I see. Ok, change the code "disable(true)" and "enable(true)" to "DisableNoWait(true)" and "EnableNoWait(true)".

The pieces should all fade simultaneously and will take about 2 seconds to fade instead of "popping".

The script won't wait for the pieces to finish fading, so putting the "wait" function (of about 3-4 seconds) AFTER the enable/disable commands (like in my last 2 script examples) is necessary to give the sound time to play. Cheers.

 

 

Ok that works very well! i just need to mess around with the wait time and its perfect. thanks for the help guys and here is a posting of the final script i used:

 

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")

int instanceID = bridgesound.play(self)

bridge1a.EnableNoWait(true)

bridge1b.EnableNoWait(true)

bridge1c.EnableNoWait(true)

bridge1d.EnableNoWait(true)

bridge1e.EnableNoWait(true)

bridge2.DisableNoWait(true)

Utility.Wait(4.0)

Sound.StopInstance(instanceID)

EndEvent

EndState

 

State On

Event OnActivate(ObjectReference akActionRef)

GoToState("Off")

int instanceID = bridgesound.play(self)

bridge1a.DisableNoWait(true)

bridge1b.DisableNoWait(true)

bridge1c.DisableNoWait(true)

bridge1d.DisableNoWait(true)

bridge1e.DisableNoWait(true)

bridge2.EnableNoWait(true)

Utility.Wait(4.0)

Sound.StopInstance(instanceID)

EndEvent

EndState

 

 

 

 

***Note: I had to switch the enable/disable states as you can notice above. Bridge1a-e were initially disabled in game while bridge2 was enabled. the original script you guys sent me had the first one set to disable bridge1a-e and enable bridge2 which it was already set that way in game, which is why it took two times to activate the lever before i saw it work. switching the two fixed the problem. thank you!

Edited by kane4355
Link to comment
Share on other sites

***Note: I hate to switch the enable/disable states as you can notice above. Bridge1a-e were initially disabled in game while bridge2 was enabled. the original script you guys sent me had the first one set to disable bridge1a-e and enable bridge2 which it was already set that way in game, which is why it took two times to activate the lever before i saw it work. switching the two fixed the problem. thank you!

 

If you check my post from 04 June 2012 - 01:50 PM, I suggested an alternative version of fg109's script that doesn't use states, and has an "If" statement to check which parts of the drawbridge are enabled/disabled so that that problem wouldn't happen. I'm such a smartypants 8) ;D

Link to comment
Share on other sites

***Note: I hate to switch the enable/disable states as you can notice above. Bridge1a-e were initially disabled in game while bridge2 was enabled. the original script you guys sent me had the first one set to disable bridge1a-e and enable bridge2 which it was already set that way in game, which is why it took two times to activate the lever before i saw it work. switching the two fixed the problem. thank you!

 

If you check my post from 04 June 2012 - 01:50 PM, I suggested an alternative version of fg109's script that doesn't use states, and has an "If" statement to check which parts of the drawbridge are enabled/disabled so that that problem wouldn't happen. I'm such a smartypants 8) ;D

 

i know i saw it.

Link to comment
Share on other sites

  • 2 months later...
  • Recently Browsing   0 members

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