steve40 Posted June 5, 2012 Share Posted June 5, 2012 (edited) 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 June 5, 2012 by steve40 Link to comment Share on other sites More sharing options...
steve40 Posted June 5, 2012 Share Posted June 5, 2012 (edited) 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 June 5, 2012 by steve40 Link to comment Share on other sites More sharing options...
kane4355 Posted June 5, 2012 Author Share Posted June 5, 2012 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 More sharing options...
steve40 Posted June 5, 2012 Share Posted June 5, 2012 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 More sharing options...
kane4355 Posted June 6, 2012 Author Share Posted June 6, 2012 (edited) 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 AutoObjectReference Property bridge1b AutoObjectReference Property bridge1c AutoObjectReference Property bridge1d AutoObjectReference Property bridge1e AutoObjectReference Property bridge2 AutoSound Property bridgesound Auto ;Thanks Cipscis - http://www.cipscis.c...als/states.aspxAuto 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) EndEventEndState 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) EndEventEndState ***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 June 6, 2012 by kane4355 Link to comment Share on other sites More sharing options...
steve40 Posted June 6, 2012 Share Posted June 6, 2012 ***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 More sharing options...
kane4355 Posted June 6, 2012 Author Share Posted June 6, 2012 ***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 More sharing options...
kane4355 Posted August 9, 2012 Author Share Posted August 9, 2012 Here is the mod uploaded: http://skyrim.nexusmods.com/mods/22020/ endorse it if you like it :) Link to comment Share on other sites More sharing options...
Recommended Posts