Suggestions on how to deal with a vanilla script

Post » Thu Jun 21, 2012 6:59 pm

I'm trying to polish up some stuff at the beginning of my quest, and there is a vanilla enable marker and script I would like some suggestions on how to deal with an issue it is causing for me.

Here's the script:

Spoiler
scriptName dunPostHelgenEnableScript extends ObjectReferencefloat property myDaysPassed autoGlobalVariable property gGameDaysPassed autoLocation property myLocation autoObjectReference property myBridgeDebris autoObjectReference property myBridge autoObjectReference myLink;****************************Event onLoad()myLink = getLinkedRef() as ObjectReferenceif (myDaysPassed <= gGameDaysPassed.getValue()) && (game.getPlayer().IsInLocation(myLocation) == false)myLink.enable()myBridge.disable()myBridgeDebris.disable()disable()endifendEvent;****************************

All it does is enable and disable some stuff in and around Helgen 4 days after the marker in Whiterun is loaded. However, because of the &&, the player has to enter Whiterun, have 4 days pass, leave Whiterun, and upon entering again and loading the marker again it finally does its thing.

Now, I'm disabling the stuff I don't want that it enables, but this script presents a bit of a problem for me because it would be possible to start my quest, get to the proper stage where I disable the stuff I don't want, and have this script enable these objects when I don't want them to.

One thing I thought about but have no clue if its even possible was to check if this script is running and if it still is and kill it so it won't enable it's objects.

Any suggestions?
User avatar
Gwen
 
Posts: 3367
Joined: Sun Apr 01, 2007 3:34 am

Post » Thu Jun 21, 2012 7:40 pm

I'm trying to polish up some stuff at the beginning of my quest, and there is a vanilla enable marker and script I would like some suggestions on how to deal with an issue it is causing for me.

Here's the script:

Spoiler
scriptName dunPostHelgenEnableScript extends ObjectReferencefloat property myDaysPassed autoGlobalVariable property gGameDaysPassed autoLocation property myLocation autoObjectReference property myBridgeDebris autoObjectReference property myBridge autoObjectReference myLink;****************************Event onLoad()myLink = getLinkedRef() as ObjectReferenceif (myDaysPassed <= gGameDaysPassed.getValue()) && (game.getPlayer().IsInLocation(myLocation) == false)myLink.enable()myBridge.disable()myBridgeDebris.disable()disable()endifendEvent;****************************

All it does is enable and disable some stuff in and around Helgen 4 days after the marker in Whiterun is loaded. However, because of the &&, the player has to enter Whiterun, have 4 days pass, leave Whiterun, and upon entering again and loading the marker again it finally does its thing.

Now, I'm disabling the stuff I don't want that it enables, but this script presents a bit of a problem for me because it would be possible to start my quest, get to the proper stage where I disable the stuff I don't want, and have this script enable these objects when I don't want them to.

One thing I thought about but have no clue if its even possible was to check if this script is running and if it still is and kill it so it won't enable it's objects.

Any suggestions?

I have not seen a way to check if a script is running... two thoughts:
1. What is the trigger to cause the vanilla script to run? Maybe you can block the trigger from happening during your state?
2. You could check the enable state of the objects directly using http://www.creationkit.com/IsEnabled_-_ObjectReference. Then disable them in your quest. (And restore them when you're done.)

I don't know if this is the best way to approach the issue as I haven't done anything along these lines.
User avatar
IsAiah AkA figgy
 
Posts: 3398
Joined: Tue Oct 09, 2007 7:43 am

Post » Thu Jun 21, 2012 6:01 pm

I have not seen a way to check if a script is running... two thoughts:
1. What is the trigger to cause the vanilla script to run? Maybe you can block the trigger from happening during your state?
2. You could check the enable state of the objects directly using http://www.creationkit.com/IsEnabled_-_ObjectReference. Then disable them in your quest. (And restore them when you're done.)

I don't know if this is the best way to approach the issue as I haven't done anything along these lines.

1- It's triggered with the OnLoad and the marker is in the Whiterun World Cell.

2 - yeah, I'm doing that a bit later, but the problem is that you have to enter Whiterun to load the marker the first time, wait 4 days, leave Whiterun and then re-enter the cell for it to load the 2nd time and do its thing. I was trying to figure out a way not to have to make the player go through those hoops in order for it to finish it's script. I can't have those objects enabled after I've already disabled them in my mod.

However, what if I simply use a quest stage in my quest to disable the marker the script is attached to? Won't that prevent it from loading the 2nd time if the timer is still running or the player has not entered Whiterun the 2nd time? It can't run the OnLoad event if it's disabled, right? I believe that would solve my problems as I'm dealing with everything that vanilla script deals with in my mod.
User avatar
sexy zara
 
Posts: 3268
Joined: Wed Nov 01, 2006 7:53 am

Post » Thu Jun 21, 2012 2:34 pm


However, what if I simply use a quest stage in my quest to disable the marker the script is attached to? Won't that prevent it from loading the 2nd time if the timer is still running or the player has not entered Whiterun the 2nd time? It can't run the OnLoad event if it's disabled, right? I believe that would solve my problems as I'm dealing with everything that vanilla script deals with in my mod.

I haven't used quest stages, but that does sound like the way to go. I'd test with the http://www.creationkit.com/Disable to make sure those events don't fire. The script does still execute and I still process OnUpdate from disabled, but from what I read, the OnLoad event shouldn't fire.
User avatar
Dezzeh
 
Posts: 3414
Joined: Sat Jun 16, 2007 2:49 am

Post » Thu Jun 21, 2012 12:47 pm

Use an OnUpdate Event besides the OnLoad Event in the script, and turn it off and on with RegisterForUpdate(1)/UnregisterForUpdate. Once the script did its thning just tell it to unregister. Make it so:

scriptName dunPostHelgenEnableScript extends ObjectReferencefloat property myDaysPassed autoGlobalVariable property gGameDaysPassed autoLocation property myLocation autoObjectReference property myBridgeDebris autoObjectReference property myBridge autoObjectReference myLink;****************************Event onLoad()	 myLink = getLinkedRef() as ObjectReference	 If (myDaysPassed <= gGameDaysPassed.getValue()) && (game.getPlayer().IsInLocation(myLocation) == false)		  RegisterForUpdate(1)	 Else		  UnregisterForUpdate()		 EndIfEndEventEvent OnUpdate()	 myLink.enable()	 myBridge.disable()	 myBridgeDebris.disable()	 disable()	 ;UnregiserForUpdate() <---------------------- this makes it so that your stuff gets enabled/disabled only once after the updateEndEvent;****************************
User avatar
sharon
 
Posts: 3449
Joined: Wed Nov 22, 2006 4:59 am

Post » Thu Jun 21, 2012 12:34 pm

Thanks for the feedback everybody. I think I've figured out something I missed earlier. I've been doing some more testing and I think I was in error in interpreting that that vanilla script. The player does not have to enter Whiterun for the timer to begin tracking the gGameDaysPassed unless I totally goofed in my testing. I exited the Helgen cave, waited there for the 4 days that myDaysPassed in the script is set to, entered Whiterun after that amount of time, and the marker loaded, checked the (myDaysPassed <= gGameDaysPassed.getValue()) which was valid and did its thing. So, I just set my messenger to only enable after 4 days as well, and since he is in The Drunken Huntsman, the player will have to enter Whiterun and cause that script to run like I need it to before the next part of my quest has started. So, unless I totally missed something, I think it's all good. If you see anything I missed please let me know.

Thanks again!
User avatar
Abel Vazquez
 
Posts: 3334
Joined: Tue Aug 14, 2007 12:25 am


Return to V - Skyrim