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)
====[edit source]
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
====[edit source]
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)
====[edit source]
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)
====[edit source]
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)
====[edit source]
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)
====[edit source]
So, question. Originally I was planning on using a cloak effect to get my mod to know when the player went through a door, but after reading that you can't attach scripts that way to doors, I guess my only option is the alias approach. However, I'm thinking that getting the quest reset so often might be kinda troublesome if you're attaching a script that might take longer than what it takes to reset it.
Would it be a bad idea to have each alias "manage itself" instead? Relay the OnUpdate event through a ModEvent, and then have the alias simply scan for whatever you need to fill it with, or just throw a Clear command to it if nothing comes out.
Since there are some conditions that don't have a proper equivalent for scripts, maybe the opposite could be done, make the alias "give permission" to the resetting function by having some sort of flag enabled. --Darkitow (talk) 2015-01-19T08:37:58 (EST)
Effect Conditions vs. Spell Effect List Conditions[edit source]
In this tutorial the conditions determining whether the apply effect occurs are stored within the effect itself, is this for any particular reason? I would have thought that it would be more efficient to place these inside the apply spell instead, to prevent the effect being called up at all unless it's needed, but maybe I'm overthinking it?
So, is there any particular reason why these conditions are within the apply effect rather than the apply spell, or does it make no difference? -- Haravikk (talk) 2018-07-14T13:02:47 (EDT)