Talk:Dynamically Attaching Scripts
I'm finished with writing this, but the article could use some pictures and more linking. If someone wants to add more examples, that would be nice too. Thanks. --Fg109 03:17, 15 April 2012 (EDT)
====
Nothing links to this page. I'm new to this wiki, so I would not know where to put the link, but it's probably a good idea. --tox2ik
====
I just posted a pretty big rewrite, including images and new info. It's still coming together so if you have any issues please raise them here --Jonwd7 (talk) 23:47, 11 September 2012 (EDT)
====
Following the instructions on this page, I have created a damage notification mod[1]. As far as I can tell, everything works, except for the Apply Effect. I can manually add the Monitor Ability to actors, but the Apply Spell will not automatically add them. Any ideas on why this might be? --Thalioden (talk) 2013-06-08T12:05:56 (EDT)
====
I have just tried to make a spell setup exactly like this (albeit with a different script) and had the same problem as Thalioden. However, changing the duration of the applying spell from 0 to 1 solved the problem and my spell was applied as intended. I am going to update the page with a note suggesting this change for the time being. If I'm incorrect or this should work with a 0 duration somehow, feel free to update, but I'm certain that this was crucial to make the cloak spell work for me. --Egocarib (talk) 2013-09-08T00:58:05 (EDT)
I was considering adding a whole new section to this explaining what I call a "manager script" which is just a (in my opinion much nicer) way of dealing with quest aliases. I am sure people have done this before, but I effectively rolled my own recently after I was unable to find any helpful advice on the topic, so here I will describe it to hopefully help some other people.
Basically, I was having a problem some time ago regarding trying to run some papyrus when an alias was changed (that is, when an alias changed to an object, I wanted to run a final script on the old object - this is impossible since the alias is already gone by that time), and events like OnReset weren't working properly, so I had to effectively manage the aliases inside a script. This is probably less than ideal and can be improved upon, but the system worked somewhat well.
First, I created a quest with a manager script, which was responsible for restarting the alias quest (which simply stored 4 or 5 aliases correspinding to the closest 5 objects of a given type) periodically (using OnUpdate) and which held the contents of those aliases in properties on the manager script (each alias had an OnInit block which set a property in the manager script). This meant I was able to keep a record of which objects had been placed into the quest aliases even after the quest had restarted. Then, on every OnUpdate call I was able to do a simple check for each object against each alias - if they were different objects, I ran the script I wanted to run, and set the property to the new object.
This method also gave me another distinct advantage. I was doing some pretty heavy processing on each object every time the alias was initialised, and having to do it once every second or so was (probably) very taxing on the script system and would have potentially caused problems (I even started to notice a weird lag when trying to activate these objects, as their OnInit process was taking literally forever). I was instead able to run these scripts only when the contents of the alias were different to what was in the properties, meaning that if a player stood still or was in an area where there was only, say, one of the specified type of object then, as long as it was still the closest, the processing was only done once.
I hope this made sense and wasn't a complete waste of time. If anyone found this in any way helpful I might consider completely re-writing it with examples and posting it on the article, as it could help some people with the same problems. -PlausibleSarge (talk) 2013-09-11T06:25:51 (EDT)