Jump to content

Monitor a global variable to reset Script


Deleted4782829User

Recommended Posts

I am working on a script that uses a global variable to set a timer for an onupdate event.

the problem is that, i need to be able to change this global variable and the script needs to notice the change and reset the timer.

i have tried to manually reset the xmarker that the script is in with a different script to make the timer reset, but it didn't work.

 

in the end my question is this, can you reset a script directly from another script? or have it monitor a global variable and reset itself?

Edited by Guest
Link to comment
Share on other sites

You need to add the global variable as a property before you can do anything with it. So you would need a line that looks like this in your script "GlobalVariable Property YourGlobalVarName Auto" (without quotes). Don't forget to go into the properties window like you would any property and set it to the correct global variable. You then have to use these functions to set or get the global variables value as it can't just be read or assigned a value like a standard variable: http://www.creationkit.com/GlobalVariable_Script

 

And yes you could reset a script from another script if you created a reset function in one script and then had the other script call the function. Check out the first script example here for the maintenance/update example: http://www.creationkit.com/Complete_Example_Scripts#Maintenance.2Fupdate_code_which_runs_once_per_save_load_and_shows_a_message_when_a_mod_is_updated_or_first_loaded

 

In the example script you can clearly see the second script (separated by all the stars like *******************) calling a function on the first one by using the name of the script as a property so "YourQuestScript Property QuestScript Auto" and then calling the maintenance function that is in the other script in the load event like this "QuestScript.Maintenance()". You could adapt that script example for your own use by creating a reset function instead of maintenance and calling it from the other script. Remember to change YourQuestScript to the name of your own script that you are calling the reset function on. And because the script is added as a property you also need to set the property to point to your other script in the propertoes window.

Edited by djjohnjarvis
Link to comment
Share on other sites

  • 1 month later...

Alright, i got it all to work as i wanted.

 

the really big problem i had was that, reset() didn't work when the xmarker wasn't loaded.

 

i made a new quest and then applied my script to it.

 

made the quest start game enabled.

 

now when the quest starts there is a RegisterForSingleUpdate

 

and when it updates it does a .TryToReset() on my reference aliases, now i can reset object/creatures in tamriel without having a xmarker or anything else.

 

when the script is done reseting, it will RegisterForSingleUpdate again and this will keep going on, creating a new reset circle independent from the standard ingame.

 

the only problems i have found are; that i have to use .TryToMoveTo(MarkerRef) to move them to a safehaven so they don't fall through the terrain.(not without minor issues)

and the other problem is that i am using this script on dragons, when the dragons are reset (if the player hasn't collected their souls but has killed them before) they will spawn and when they do, the player will take their soul on contact...

creating flying skulldragons that will attack the player like regular dragons.

 

i am currently looking for a way to reset an actors attached scripts, to prevent this.

 

and thanks for the help @djjohnjarvis

Link to comment
Share on other sites

  • Recently Browsing   0 members

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