Page 1 of 1

Local variables for each dialog?

Posted: Thu Nov 23, 2017 10:31 am
by namelesswc
Is there a way to have local variables for a dialogue instead of having all variables in the variables tab?

My scenario:
Node1 has links to Answer1 and Answer2. After Answer1 has been selected, it leads back to Node1 but now there is an additional Answer3 avaiable.

Current solution: I create a bool variable e.g. "Scene3/Dialogue3/Answer3Discovered" and set it to true after answer 1 has been clicked. The problem I have is that the variable tab doesn't group folders and it can become quite bloated overtime.

In the AllFields tab of each dialogue entry I can add my own fields. Can I use there as variables inside the dialogue? If so, how can I access a field from the same dialogue but from another node?

Re: Local variables for each dialog?

Posted: Thu Nov 23, 2017 7:13 pm
by Tony Li
Hi,

The dialogue database format uses global variables, but not local variables, to maintain compatibility with third party editing software such as Chat Mapper and Aurora Toolset.

You can sort the list of Variables by name to organize them, although I know this isn't quite the same as collapsing groups.

You can certainly use custom fields in your dialogue entry or in the conversation like local variables. (To edit the conversation's properties and fields, click on a blank area of the canvas.) Here are a few things to keep in mind:
  • Conversations' fields are added to the runtime Lua environment. To keep memory use low, dialogue entries' fields are not added to Lua, except for SimStatus if you've ticked the Dialogue Manager's Include SimStatus checkbox.
  • Conversations' fields are not saved in saved games, although that will be an option in the upcoming version 1.7.7.
  • Conversations and dialogue entries are accessed by ID number. For example, let's say in conversation 2 you add a field named NumTimes. Then you could add this Script to your <START> dialogue entry node:

    Code: Select all

    Conversation[2].NumTimes = Conversation[2].NumTimes + 1
    And you could check that in another node:
    • Dialogue Text: "You sure are persistent."
      Conditions:

      Code: Select all

      Conversation[2].NumTimes > 3
  • To access fields in your C#/UnityScript scripts, use DialogueManager.MasterDatabase.GetConversation() or GetDialogueEntry().