Page 1 of 1

Using my own game stats with dialogue system?

Posted: Fri Apr 04, 2025 5:00 pm
by Rockoo
So I have just started using the dialogue system for a fairly complex RPG I am developing. I (think) I understand it, but I'd just like to double check some things:

(1): So the database is read-only in all instances and upon starting the game a runtime copy gets loaded in for Lua to process, and then any changes made to the Lua runtime copy are lost when the game quits?

(2): Related to this, I have a variety of player stats, items, etc. which are contained within Unity C# data structures currently. I wish to use these for various conditions and scripts within dialogue in the conversations manager - must they therefore be set for the database manager using 'DialogueLua.SetVariable'?

(3) Finally, and kind of the most important point, does the following make sense as an order of operations whenever the game restarts from a save file?
  • When we load in from save data all relevant values are loaded in from serialisation to the actual Unity game data
  • A script on Start or Awake assigns any relevant values for the dialogue database via DialogueLua.Set...
  • Then if a variable changes in the C# data during runtime, it is set again in the database via DialogueLua.Set...
  • When the game is saved the data is serialised using the save system but this does NOT affect the actual databse itself since it is read only. Hence, this process must be repeated whenever the game is re-loaded.
Apologies if this has all been covered elsewhere - I'm fairly new to this sort of programming and I'd just like to clarify it all. Thanks!

Re: Using my own game stats with dialogue system?

Posted: Fri Apr 04, 2025 9:45 pm
by Tony Li
Hi,

The Dialogue System includes a save system that you can use to save all Dialogue System information and optionally anything else you want to save. (Most other games that use the Dialogue System, such as Disco Elysium, Eternights, While The Iron's Hot, 1000xRESIST, etc.) use the Dialogue System's save system to save everything.) You can use it to save all of your RPG data. See: How To: Write Custom Savers

To access your own C# data inside conversations, please see: How To: Connect C# Variables to Dialogue System's Lua

Re: Using my own game stats with dialogue system?

Posted: Sat Apr 05, 2025 3:42 am
by Rockoo
Hi Tony,

I see - that makes sense thanks. So just as a final check, does that mean that any variables from within the database that change in the game can be serialised, saved, and loaded again just like any other data?

Re: Using my own game stats with dialogue system?

Posted: Sat Apr 05, 2025 7:30 am
by Tony Li
Yes. If you only want to save Dialogue System variables and quest states, the save system manual page (linked above) has a line of code for that. But if you want to save more, including an entire saved game for everything in the game, you can use the full save system.