Noob question - accessing database variables with C# scripts

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ORCONECTESLIMOSUS
Posts: 8
Joined: Sun Jan 19, 2025 11:26 am

Noob question - accessing database variables with C# scripts

Post by ORCONECTESLIMOSUS »

Hello!

As title says, i'd like to know a way to access the variables (numbers and booleans) set in the dialogue database.
My approach to branching dialogue that affects the world outside is to have the bulk of the checks and conditions happening within the comfy dialogue manager system, with a large, "End of day" C#script that checks some of the variables for more complex stuff such as spawning objects and altering variables outside of the database.

I know it has a simple solution, but as a very amateurish coder i still prefer to have a direct answer to avoid banging my head on a brick wall for hours.
Thanks a lot!
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Noob question - accessing database variables with C# scripts

Post by Tony Li »

Hi,

Use the DialogueLua class. Examples:

Code: Select all

using PixelCrushers.DialogueSystem;
...
DialogueLua.SetVariable("Score", 7);
DialogueLua.SetVariable("FoundSecretEntrance", true);
bool hasTheMaguffin = DialogueLua.GetVariable("HasMaguffin").asBool;
int health = DialogueLua.GetVariable("Health").asInt;
Post Reply