Observer Callback Garbage

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Dennis
Posts: 1
Joined: Tue Apr 08, 2025 10:02 am

Observer Callback Garbage

Post 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
Attachments
Screenshot 2025-04-08 160735.png
Screenshot 2025-04-08 160735.png (262.16 KiB) Viewed 253 times
User avatar
Tony Li
Posts: 23252
Joined: Thu Jul 18, 2013 1:27 pm

Re: Observer Callback Garbage

Post 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.
Post Reply