Extra Database - Accessing Variables

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
callen
Posts: 10
Joined: Tue Jun 09, 2020 3:44 pm

Extra Database - Accessing Variables

Post by callen »

Hey, I'm playing with the structure for my game and I was hoping to use ExtraDatabase component for certain things. Such as, controlling an entire minigame in dialogue.

This one complex conversation has lots of variables, but they only matter from the beginning to end of the 'conversation' (which encapsulates the full minigame loop). I was hoping that the variables would be usable when I merged in the minigame's database at runtime, but the values are all nil and cannot be set.

Is there any way I could get the variables to merge in? If not, is there a way to declare new variables at runtime or within a conversation (maybe by using a custom sequence command)? It would be very suboptimal to have all variables, including these very temporary ones, in the initial/main database, which I would like to only hold things that I would put in a player's save file. Is there something I'm missing that can do this, or is the backend lua system not quite set up for this use-case?

Thanks for any help!
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Extra Database - Accessing Variables

Post by Tony Li »

Hi,

When the Extra Databases component loads extra databases into memory, it should also load and initialize all variables defined in those databases. Are you sure the databases are being loaded? If the database(s) should load when you start a specific scene, set the Add Trigger to OnStart and assign your database(s) to the Databases list. To automatically unload the database and its variables from memory when leaving the scene, set the Remove Trigger to OnDestroy.

To answer your other question, you can define new variables at runtime simply by setting them.
  • Dialogue Text: "This node creates a new variable Foo and sets its value to 42."
  • Script: Variable["Foo"] = 42
callen
Posts: 10
Joined: Tue Jun 09, 2020 3:44 pm

Re: Extra Database - Accessing Variables

Post by callen »

Hmm ok that sounds like how I'd expect it to work. Weirdly, I cannot reproduce today what I saw yesterday, now after I switch scenes the conversation doesn't run. All I know is that I have the extra database component with "Once" checked, in my 2nd scene, and that component disappears at runtime (presumably because the databases merged ok, no console output is shown to make me think otherwise).

However, I might be running into ID conflicts. I'm trying to redo my database with the BaseID set, but I don't see that property anywhere as described in the docs: "On the Dialogue Editor's Database tab, you can assign values to Database Properties > Base ID for each database." In my "database properties" I see Author, Version, Description, Global User Script, and Emphasis Settings. I've looked around in the editor but can't find BaseID. So that may be the cause of my issues.

Might be worth adding that I'm not up to the latest version, I'm on 2.2.6 so maybe BaseID is super brand new, idk.
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Extra Database - Accessing Variables

Post by Tony Li »

Hi,

Yes. BaseID is fairly new.

Run your dialogue databases through the Unique ID Tool.
callen
Posts: 10
Joined: Tue Jun 09, 2020 3:44 pm

Re: Extra Database - Accessing Variables

Post by callen »

Thanks for all the help. After running the two db's in the unique id tool things are working well. I'm going to look into upgrading the version to set baseID still, because I'd like having that level of control going forward. 👍
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Extra Database - Accessing Variables

Post by Tony Li »

Sounds good! Back up your project before updating (just to be safe), and also look over the release notes for any new features or changes you might want to take advantage of.
Post Reply