jaghar7 Posted April 14, 2022 Share Posted April 14, 2022 So poking around a vanilla quest I spied the use of RegisterForUpdate(). I couldn't find much on the topic except one person who tried it seemed to end up spamming the papyrus log and seemed to think it ignored the time interval. So I'm wondering how it actually works. The impression I'm left with is that rather than calling an OnUpdate() event it simply calls the fragment, or rather the script containing the fragment. In one case I found RegisterForUpdate() in an early quest fragment and Unregister in the last fragment which suggests that it continues to run a quest's active fragment until it's told to stop? Naturally, the CK wiki doesn't address this use at all, at least not clearly. I can think of a use or two for this. If I could say.. use RegisterForSingleUpdate(x) to keep checking a fragment until the stage change or quest shutdown. But also depending on whether or the timing works properly. I don't want to tell it 60 seconds and have it end up firing 60 times per second. :) Can anyone shed light on this for me? I suppose I could just test it but it seemed like an interesting question to actually ask. :) Link to comment Share on other sites More sharing options...
jaghar7 Posted April 14, 2022 Author Share Posted April 14, 2022 Well I tried RegisterForUpdate and RegisterForSingleUpdate and got bumpkis. :P RegisterForUpdate(60)Debug.Notification("Quest Fragment Update 60s Test")Debug.Trace("Quest Fragment Update 60s Test") No compile or papyrus errors but no luck. Double checked quest was running and on the right stage on a new game. Nothing. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 14, 2022 Share Posted April 14, 2022 (edited) Any script can register for an update. The same script or any other script held on that same object will then receive the OnUpdate event (note that for this purpose an object reference is not considered the same as a quest alias pointing to the object reference). Registering for an update without using the OnUpdate event will get you as you found out "bumpkis" It should also be noted that some objects may not stay loaded long enough for the OnUpdate event to trigger. And this is what causes errors in the papyrus log especially when not using the single variants. The non-single variants of update will keep repeatedly checking until they are unregistered and if the object whose script is trying to run is no longer loaded, the code being used in the OnUpdate event may not work properly and trigger errors in the log (and in excessive cases lead to save game bloat). Furthermore, when using the single variants of update some object types will automatically unregister when they no longer exist (expired magic effects, quest aliases on stopped quests, etc). And any object running the single variant that is removed mid-game, will error once in the papyrus log and then no more after that. Stage fragments and other fragment types (perk, dialog, etc) cannot receive the OnUpdate event because events cannot be coded inside an existing function (stage fragments are nothing more than a specialized function on a larger CK created script). If you want something to happen after a set amount of time when a particular stage has been met, use the quest script itself to run the update. Have the stage fragment trigger a custom function on the quest script that registers for the update. See Getting Properties of a Quest Script for more information. EDIT: In theory, if one were to externally add the OnUpdate event to the CK created fragment script for the given quest, then one could register and unregister for the update within the fragments themselves. That, however, would need testing and possibly confirmation that the CK doesn't wipe out any externally added code to said fragment script. I suspect that this is what the one example discovered was trying to do. Edited April 14, 2022 by IsharaMeradin Link to comment Share on other sites More sharing options...
jaghar7 Posted April 14, 2022 Author Share Posted April 14, 2022 I think you pretty much covered everything there is to cover on the subject. :) Thanks. I was curious because as you surmised, the quest fragment script did not contain then OnUpdate event. One assumes that the original authors must know what they're doing after all. :) I am also curious about adding the OnUpdate. I tend to add properties by editing the script and have found that so long as it's added outside of the fragment code (ie after ;END FRAGMENT CODE) that the CK leaves it alone. Just having done a simple test I added Event OnUpdate()endEvent To the script at the very end and then went back to the quest fragment and made a change. It worked. :) Going to have to play with this later. Link to comment Share on other sites More sharing options...
Recommended Posts