Page 1 of 1

Observer Callback Garbage

Posted: Tue Apr 08, 2025 10:09 am
by Dennis
Hey, i have a script that subscribes observers to all of my quests that are in the game, in order to update stuff like the Map etc. Currently they are setup to check on Dialogue end. Problem is, on each dialogue end i get a huge spike because of the Lua code running.
Is there a way around this ?`
https://www.pixelcrushers.com/phpbb/dow ... ew&id=5857

Re: Observer Callback Garbage

Posted: Tue Apr 08, 2025 11:20 am
by Tony Li
Yes, don't use observers. :-) They're handy, but by necessity they allocate memory when running Lua code.

Instead, if you want to monitor variable values, use Language.Lua.Assignment.VariableChanged as described in Monitor Variable Value Changes.

To monitor quest state changes, use an OnQuestStateChange() method (the easiest solution) or assign an override method to QuestLog.SetQuestStateOverride. In this method, you can call QuestLog.DefaultSetQuestState() and also do your own thing.