Multiple OnInItOnUpdate Question

Post » Mon May 25, 2015 4:31 pm

I am planning on building a mod with multiple codes like this (as an example):

Scriptname Example Code extends Quest  ConditionalQuest Property example1 AutoEvent OnInit()	RegisterForSingleUpdate(1.0)EndEventEvent OnUpdate()	if (example1.GetStage() == var)		Do stuff	else		RegisterForSingleUpdate(1.0)	endifEndEvent

Essentially, some of the scripts will consist nothing but multiple OnInIt/OnUpdate/RegisterforSingleUpdate. I am aware of the issue that if the mod is ever removed that it might bark an error down the road but some authors told me that it won't affect gameplay, but my concern is about having multiple scripts like this being run on one mod. Will a multiple scripts like this cause any kind of script lag or, heaven forbid, bloat because of multiple iterations of these being used?

User avatar
Petr Jordy Zugar
 
Posts: 3497
Joined: Tue Jul 03, 2007 10:10 pm

Post » Mon May 25, 2015 4:27 am

It's unlikely to cause any problems, but there are probably better ways to trigger a script event than polling every second.

For example, you are checking a quest stage in the example - why not just put your code in the quest stage script fragment?

User avatar
Nienna garcia
 
Posts: 3407
Joined: Wed Apr 25, 2007 3:23 am

Post » Mon May 25, 2015 4:28 pm

Thanks for the reply.

Mostly because I don't want to alter Dawnguard nor Serana's original code because of Dawnguard being spazzy (IMO) to begin with nor do I want to deal with the possibility with having to clash with the unofficial patches. Also that base code (meaning the OnInIt/OnUpdate) is going to be used a rudamentary 'distance calculator' to see if the NPC was a 'witness' to certain events. For example, if my NPC wasn't around during the first cultist encounter/attack in Dragonborn then there will be a variable in place that affects future dialogue. An example of this code is here:

Scriptname SDEDLC2TriggerScript extends Quest  ConditionalQuest Property DLC2MQ01 AutoObjectReference Property Serana AutoBool Property SeranaAtDLC2MQ01 = False Auto ConditionalEvent OnInit()	if DLC2MQ01.IsStageDone(7)		SeranaAtDLC2MQ01 = false	else		RegisterForSingleUpdate(1.0)	endifEndEventEvent OnUpdate()	if DLC2MQ01.IsStageDone(7)		SeranaAtDLC2MQ01 = Game.GetPlayer().GetDistance(Serana) < 1024	else		RegisterForSingleUpdate(1.0)	endifEndEvent

My concern is that I don't want to add into the default quests as I don't want this mod conflicting with other mods down the road. That is mostly why I don't want to just add what I have in the vanilla quest stage fragment script. Again, I am sure there is a way to link a quest stage from a custom quest to the vanilla quest stage, but I haven't found it, yet.

I was mostly concerned about having multiple scripts polling every second.

User avatar
Joe Bonney
 
Posts: 3466
Joined: Tue Jul 17, 2007 12:00 pm


Return to V - Skyrim