Search Unity

[70% OFF - FLASH DEAL] Dialogue System for Unity - easy conversations, quests, and more!

Discussion in 'Assets and Asset Store' started by TonyLi, Oct 12, 2013.

  1. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Hi @Stickeyd - The Dialogue System Extras has an integration package for ES3 (direct download). I just tested it with the latest ES3 and Dialogue System versions. I'll include it in version 2.2.2+ also.

    There are a few ways to integrate them. I recommend using the ESSavedGameDataStorer included in the integration package. Add it to your Dialogue System save system in place of any existing storers such as PlayerPrefsSavedGameDataStorer or DiskSavedGameDataStorer. (This is what the integration's example scene does.)

    With this setup, the Dialogue System will manage the saving and restoring of systems -- for example, setting the enabled state of components using EnabledSaver, setting character positions using PositionSaver, etc. -- and it will use Easy Save to actually store its data.

    If you don't want the Dialogue System's save system to save and load the current scene, untick the SaveSystem component's Save Current Scene checkbox.

    If you don't want the Dialogue System to manage the overall save/load process, see the Alternate Setup steps in on the Easy Save Support page.


    Hi @Orexx - Sure! It's just Unity UI. Most of the included starter prefabs are anchored to certain edges of the screen so they adjust according to the current screen size. But you can certainly change your UI's Rect Transform values to make them fixed size.
     
  2. HellsPlumber

    HellsPlumber

    Joined:
    Aug 17, 2014
    Posts:
    42
    Hi @TonyLi !

    I'm trying to get Dialogue System to use Rewired inputs but I'm not finding much documentation.

    I've imported the 3rd party support package for Rewired and added the "DialogueSystemRewired" component to the "Dialogue Manager" prefab.

    How do I actually tell Dialogue System which Rewired button names to use for each action?
    For example, I want to use the Up/Down Dpad buttons to move between Responses.
    I have buttons set up in Rewired specifically for this, named "Dpad Up" and "Dpad Down" respectively.

    The closest thing I can find is the "Joystick Buttons to Check" option in the "Input Device Manager" component.
    But that's imply an array of button names with no way to tell Dialogue Manager WHAT each button should do.

    Any help would he greatly appreciated.
    I feel this should be relatively simple to do but I just can't find what I need.
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Hi @HellsPlumber - The dialogue UI (including the response menu) uses standard Unity UI. Set up the Unity UI EventSystem with a Rewired Standalone Input Module.

    Since the dialogue UI uses Unity UI, it doesn't rely on DialogueSystemRewired at all. You can remove thee DialogueSystemRewired component unless you plan to use the Dialogue System's Selector or ProximitySelector components. These components normally read input from Unity's standard input system. But if the Dialogue Manager has a DialogueSystemRewired component, it will read the inputs from Rewired.
     
  4. HellsPlumber

    HellsPlumber

    Joined:
    Aug 17, 2014
    Posts:
    42
    Ah, got it!
    Thanks a bunch for the help!
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Glad to help!
     
  6. megan_l_fox

    megan_l_fox

    Joined:
    Jul 10, 2010
    Posts:
    35
    Er, am I missing something, or is the TextMeshPro support completely broken? The prefab meant to show the TMP support off has 100% missing scripts where (I assume) the TextMeshPro scripts should be, and AFAICT I definitely have TMP installed. Is your code maybe assuming the old non-packagemanager version, or something?

    Also, digging into your TMP class equivalents a bit, you're seemingly just not exposing the same degree of features. It would pass a quick glance, but you've apparently not bothered to add stuff like multiple subtitle panel support.

    I'm in the midst of essentially re-engineering your TMP support, both in building a functional prefab for the dialogue system, and actually making it support the full feature set your Standard Dialogue System prefab does. It's all, needless to say, a bit frustrating. Am I missing something here?
     
  7. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Hi @megan_l_fox -
    Yes. Use the Standard Dialogue UI system. See: Enable TextMesh Pro Support for Standard Dialogue UI.

    It sounds like you may be looking at the deprecated, legacy TMP support package that was included in early 2.x versions solely for developers who were maintaining old projects. You can delete that from your project and just use Standard Dialogue UI.
     
  8. megan_l_fox

    megan_l_fox

    Joined:
    Jul 10, 2010
    Posts:
    35
    Ah HAH. Yep, that would be what I was missing. Thanks!
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Glad to help!
     
  10. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Disco Elysium Out Now

    Disco Elysium is available now on Steam. ZA/UM used the Dialogue System for Unity and articy:draft to craft some amazing dialogue. IGN UK and others are already calling it potentially game of the year.

     
  11. TonyC

    TonyC

    Joined:
    Mar 31, 2015
    Posts:
    3
    I have a problem with PlayMaker (1.9.0) and the latest version of the Dialogue Plugin (2.2.1).
    In an earlier project when I imported the PlayMaker unity package I got a whole host of new Playmaker actions:
    upload_2019-10-15_23-19-21.png

    But starting a new project, and importing the latest versions of both plugins, and importing the Playmaker unity package, I have no 'Dialogue System' set of actions, just 'Pixel Crushers Common'
    upload_2019-10-15_23-20-34.png

    I noticed something was up when I went to use an FSMEvent() command in a dialogue entry sequence and it didn't recognise the command. This worked fine in my other project (with the older version of the Dialogue Plugin).

    Just out of interest, I copied the old actions to the new project and got a lot of "The type or namespace name 'PlayMakerEditor' does not exist in the namespace 'HutongGames'" errors.

    Has something changed in the support for Playmaker, as I couldn't find anything mentioned in the build notes, or have I done something stupid when importing one or both plugins this time around?

    FYI the old project is Dialogue Plugin 2.1.8 and Playmaker 1.9.0

    Thanks in advance, Tony.
     
  12. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Hi @TonyC - You're halfway there! There are two PlayMaker Support packages.

    One is in Plugins / Pixel Crushers / Common / Third Party Support. You imported this one already.

    The other is in Plugins / Pixel Crushers / Dialogue System / Third Party Support. If you import this one, I think you should be good to go.

    (These are split into two packages so the scripts in Common can be shared among all Pixel Crushers assets to reduce duplication and keep your build size smaller.)
     
    TonyC likes this.
  13. Sigma266

    Sigma266

    Joined:
    Mar 25, 2017
    Posts:
    99
    Hey, Tony. How come when I turn off the object holding the Dialogue System Controller it somehow still works? I have to use another Controller for reasons but it kind of conflicts with the turned off one when I'm in a dialogue. I know that completely destroying the component gets rid of the issue, but doing that, bring more issues on its own(that's on me though, it's just how I developed things). Any tips?
     
  14. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Hi @Sigma266 - What's the reason for having multiple DialogueSystemController components? (Or multiple Dialogue Manager GameObjects, if that's the case.) There might be an easy way to avoid the need for that.

    While it's technically possible to have 2 Dialogue Managers in the scene, it's much easier if there is only one. You can destroy the one you're not using. You may want to save its state first. But let's see if there's a way to use a single one, since that's much simpler.
     
    Sigma266 likes this.
  15. Sigma266

    Sigma266

    Joined:
    Mar 25, 2017
    Posts:
    99
    Well, tbh I think I could find a way to make it work with only one but I wanted to make things easier for myself. But if using just one makes the system work better, then I'm going with that. Thanks, Tony.
     
    TonyLi likes this.
  16. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    I'm here to help if you have any questions about switching over to one Dialogue Manager. If you need to use different display settings for a particular conversation, there are two ways to do it:

    1. Inspect the conversation's properties in the Dialogue Editor and click Override Display Settings, or

    2. Add an Override Display Settings component to the NPC.
     
  17. TonyC

    TonyC

    Joined:
    Mar 31, 2015
    Posts:
    3
    That did the trick! Thanks :)
     
    TonyLi likes this.
  18. Sigma266

    Sigma266

    Joined:
    Mar 25, 2017
    Posts:
    99
    @TonyLi No no, it's cool, I think I got it! Thank you for being always being very supportive!
     
    hopeful and TonyLi like this.
  19. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Just wanted to post a congratulations to ZA/UM on the success of Disco Elysium! (Made with the Dialogue System for Unity.) IGN just gave it the highest score of any game they've reviewed this year, and its Metacritic score is a super impressive 93. You can get it on Steam or GOG (bundled with a free copy of isometric RPG UnderRail on GOG).
     
  20. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Jinx-It Games' dark fairy tale adventure Framing Dawes, made with the Dialogue System for Unity, is now available to wishlist on Steam:

     
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Way of Wrath at Game Industry Conference

    If you're at the Game Industry Conference in Poland, stop by Animmal's booth and check out The Way of Wrath, made with the Dialogue System:

     
  22. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Dialogue System for Unity 2.2.2 Released

    Version 2.2.2 is now available on the Asset Store!

    This version includes updates to several integration packages, including Easy Save, Adventure Creator, Corgi, uMMORPG, and more.


    Release Notes:
    Core:
    • Changed: ConversationStateSaver is now a Saver component, not a PersistentData component.
    • Changed: Dialogue database content dropdowns now show "Name [ID]" instead of "[ID] Name" to support submenus with forward slash (/).
    • Improved: Made UnityUITypewriterEffect variables & methods protected/virtual.
    • Fixed: Setting localized language back to blank string now sets it to the default language.
    • Fixed: MoveTo() sequencer command on kinematic rigidbodies.
    • Fixed: Setting localized language back to blank string now sets it to the default language.
    Third Party Support:
    • Adventure Creator: Added Copy DS Vars To AC button.
    • Corgi Platformer Engine: Added Hide Prompt Only During Conversations checkbox; updated for 6.0.
    • Easy Save: Added support package and documentation.
    • Emerald AI: Updated for 2.3.0.2.
    • i2 Localization: Added zeroes-padding option for dialogue entries to improve sorting.
    • Ink: Added Dialogue System Ink Trigger, ability to start at knots and stitches.
    • TopDown Engine: Added Hide Prompt Only During Conversations checkbox; updated for 1.5.1.
    • uMMORPG: Added server-side authorization; updated for 1.179.
    • uRPG: Added more Lua functions; updated for 1.18.
    • uSurvival: Updated for 1.67.
     
    DMRhodes likes this.
  23. DMRhodes

    DMRhodes

    Joined:
    May 21, 2015
    Posts:
    81
    Does this change have any implications for currently existing save systems in a project or can I upgrade without worrying?

    Cheers!
     
  24. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    @Candy-Bomber - As long as your project is set up with a Save System component, you should see no difference.

    The only time you'd see a difference is if you're bypassing the save system and manually calling PersistentDataManager.GetSaveData() instead.
     
    DMRhodes likes this.
  25. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Jon Ingold Article: Designing Investigate Conversations

    Jon Ingold of Inkle posted a very good article on how they're designing conversations for Heaven's Vault:

    Designing Investigate Conversations (Gamasutra)

    The strategies they developed were:

    1) Know your known knowns and your known unknowns. Your data model. In the Dialogue System, you can use variables, custom actor fields, and other techniques to remember the player's responses and actions.

    2) Say hello! Start conversations with a bit of greeting before jumping into the Q&A. This is straightforward enough in the Dialogue System, but you can also use cross-conversation links to always start with a greeting conversation and then branch to other conversations based on conditions.

    3) Take turns! The player asks a question, the NPC responds, then the NPC gets to say something related to their interests or goals.

    4) Constrain the scene. Set a time limit or response limit, and let the NPC end the conversation if the limit is reached. In the Dialogue System, you can increment a variable whenever the player asks a question, or run a timer. If the limit is reached, jump to a "goodbye" entry or simply have the NPC walk away while speaking a bark.

    5) Constrain the questions. If the player can ask the NPC a long list of questions, don't bombard the player with a long response menu right away. Restrict the response menu to the priority questions plus a limited number of questions relevant to the current topic of discussion. You can use conditions or script methods to do this in the Dialogue System.

    If you have any questions about how to implement the article's suggestions using the Dialogue System, just let me know!
     
  26. romandutov

    romandutov

    Joined:
    Sep 18, 2015
    Posts:
    16
    Hi @TonyLi.

    I have action node and code for sequencer:

    Code (CSharp):
    1.  
    2. GoUpgradeItem(Kitchen_1_Wall, 1);
    3.  
    4. CancelDialog()@Message(Cancel);
    5.  
    6. ClearAllDialogCommands()@Message(Done);
    7. CompleteTaskClaimCert(0)@Message(Done);
    8. ActivateTodoTask(1, true)@Message(Done);
    9. Continue()@Message(Done);
    10.  
    11. required SetContinueMode(false);
    GoUpgradeItem - sequence command, wich generate same messages - Done for success and Cancel for decline.
    CancelDialog - sequence command, wich cancel current conversation.
    And have same block for Done message, which do something and continue dialog.
    But when i generate Done message, exec only Continue()@Message(Done);
    Without that:

    Code (CSharp):
    1. ClearAllDialogCommands()@Message(Done);
    2. CompleteTaskClaimCert(0)@Message(Done);
    3. ActivateTodoTask(1, true)@Message(Done);
    Adding require tag it's solution, but that sequence command above exec any way ( if doesn't take message Done ). Such as :

    Code (CSharp):
    1. required ClearAllDialogCommands()@Message(Done);
    2. required CompleteTaskClaimCert(0)@Message(Done);
    3. required ActivateTodoTask(1, true)@Message(Done);
    4. required Continue()@Message(Done);
    How to change that for logic if-else block?

    P.S.: I found solution
    Code (CSharp):
    1. GoUpgradeItem(Kitchen_1_Wall, 1);
    2. CancelDialog()@Message(Cancel);
    3.  
    4. ClearAllDialogCommands()@Message(Done);
    5. CompleteTaskClaimCert(0)@Message(Done);
    6. ActivateTodoTask(1, true)@Message(Done)->Message(Cont);
    7. Continue()@Message(Cont);
    8.  
    9. required SetContinueMode(false);
     
    Last edited: Oct 25, 2019
  27. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Hi @romandutov - That's a fine solution. It guarantees that the commands that are waiting for "Done" finish first, and then the command that is waiting for "Cont" will run.
     
  28. huntersteeger

    huntersteeger

    Joined:
    Dec 27, 2017
    Posts:
    19
    Do you have updated documentation for Emerald AI Integration in development? It would be nice to have more LUA functionality!
     
  29. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    The Dialogue System Extras page has an updated integration package with these additions:
    • SetEmeraldFactionRelation("faction", "targetFaction", "relation")
      Sets the AI's relation to targetFaction to "Enemy", "Neutral", or "Friendly".
      Example: SetEmeraldFactionRelation("NPC", "Undead", "Enemy")

    • EmeraldAIAttacksPlayer(“faction”, true|false)
      Sets the Emerald AI's "Attacks Player" dropdown to Always (true) or Never (false).

    • You can specify a single GameObject instead of an entire faction using “go=Name” as the faction, where Name is a GameObject name.
      Example: EmeraldAIFollow(“go=Porthos”, “Player”, “Companion”)
      Makes the Emerald AI whose GameObject is named "Porthos" follow the Player as a Companion.
     
    Last edited: Oct 31, 2019
    huntersteeger likes this.
  30. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    @huntersteeger - If you have Love/Hate, the Love/Hate Extras page also has an update for its Emerald AI integration that updates Emerald AI faction relations and behaviors based on Love/Hate affinities. This allows them to change dynamically at runtime instead of always staying the same value you set at design time.
     
    huntersteeger and TeagansDad like this.
  31. Orexx

    Orexx

    Joined:
    Jun 4, 2017
    Posts:
    26
    Hi @TonyLi
    Is it possible to somehow reduce the delay when the dialog editor fulfills the condition (for example, GetBBInteger1("typeCab") == 0, the method first searches for an object with a specific name on which the variable Blackboard stands), because it turns out that it takes several seconds before a choice is made and the text starts appearing in dialog box?
    Is it possible to compare in a condition the value of a variable taken from PlayerPrefs? (maybe it will be faster)
     
  32. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Hi @Orexx - If I understand your situation correctly, the delay is the dialogue entry's Sequence. Inspect the Dialogue Manager and change Camera & Cutscene Settings > Default Sequence to: None()

    Every dialogue entry will pause for the duration of its Sequence. For example, this dialogue entry will last for 3 seconds:

    upload_2019-11-2_8-19-30.png

    If the dialogue entry's Sequence field is blank, it will use the Dialogue Manager's Default Sequence. The Default Sequence starts with this value: Delay({{end}})

    This delays for the duration of the special keyword {{end}} which is based on the Dialogue Text length and the Subtitle Settings values:

    upload_2019-11-2_8-23-53.png

    If you set the Default Sequence to None(), it will not delay at all. To delay for a shorter time, reduce Min Subtitle Seconds and increase Subtitle Chars Per Second. This will reduce the value of {{end}}

    More info: Cutscene Sequence Tutorials
     
  33. Zoraph

    Zoraph

    Joined:
    Aug 23, 2012
    Posts:
    29
    Hi,
    I updated to your latest version Version 2.2.2 and I got this error message:

    Assets\Plugins\Pixel Crushers\Dialogue System\Wrappers\Options\Cinemachine\CinemachineCameraPriorityOnDialogueEvent.cs(16,90): error CS0234: The type or namespace name 'CinemachineCameraPriorityOnDialogueEvent' does not exist in the namespace 'PixelCrushers.DialogueSystem' (are you missing an assembly reference?)

    I looked into the code and it is there but unity can't see it. I went to the welcome screen of pixel crusher and ticked cinemachine and also reimported the third party integration just in case but that did nothing...

    I am using unity 2019.1.14f1 and cinemachine 2.3.4
     
  34. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Hi @Zoraph - In the Project view, please navigate to Plugins > Pixel Crushers > Dialogue System > Scripts > Options. Then right-click on the Cinemachine folder and select Reimport. Since Unity's package manager is still in rollout mode in many versions of Unity, it sometimes needs to be told to recompile after adding scripting define symbols such as USE_CINEMACHINE. If that doesn't fix the issue, please let me know.
     
  35. Zoraph

    Zoraph

    Joined:
    Aug 23, 2012
    Posts:
    29
    I tried and it didn't work. I am trying the same on the entire dialogue system folder both from wihtin plugins and the the one inside the PixelCrusher from the root folder just in case...
     
  36. Zoraph

    Zoraph

    Joined:
    Aug 23, 2012
    Posts:
    29
    both didn't work
     
  37. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    @Zoraph - In this case, you probably have an old Cinemachine Support folder left over from an older installation. Please use these steps:

    1. Delete this folder: Assets / Pixel Crushers / Dialogue System / Third Party Support / Cinemachine Support.

    2. Reimport the Dialogue System -- at least the Scripts folder -- to make sure you still have all the Cinemachine integration scripts.
     
  38. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Updated Integrations: Emerald AI, Invector, ORK Framework

    The Dialogue System Extras page has updated integration packages for these products:

    • Emerald AI:
      • SetEmeraldFactionRelation(“faction”, “targetFaction”, “relation”)
        Relation can be “Enemy”, “Neutral”, or “Friendly”.
      • EmeraldAIAttacksPlayer(“faction”, true|false)
      • You can specify a single GameObject instead of an entire faction using “go=Name” as the faction, where Name is a GameObject name.
        Example: EmeraldAIFollow(“go=Porthos”, “Player”, “Companion”)
    • Invector: Patch adds an option to only rotate on Y-axis when using Face Conversant option.
    • ORK Framework: Updated for ORK Framework 2.27.0.
     
    SamRock likes this.
  39. Zoraph

    Zoraph

    Joined:
    Aug 23, 2012
    Posts:
    29
    It worked thanks :)
     
    TonyLi likes this.
  40. Froghuto

    Froghuto

    Joined:
    Oct 4, 2012
    Posts:
    61
  41. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
  42. Froghuto

    Froghuto

    Joined:
    Oct 4, 2012
    Posts:
    61
    Oh, thanks!
    Then my followup question: is there an example or page in the documentation on how to use the Bark Dialogue UI component?
     
  43. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Once your characters are set up with Bark UIs, add a Bark Dialogue UI component and an Override Dialogue UI component to one of the characters involved in the conversation. Assign the Bark Dialogue UI component to the Override Dialogue UI.

    However, instead of using a Bark Dialogue UI, most folks are now using overhead subtitle panels for characters. It gives you more flexibility. Briefly:
    1. Add a Dialogue Actor component to the character.
    2. Set the Dialogue UI Settings > Subtitle Panel Number to Custom, and assign a subtitle panel prefab such as "Bubble Template Standard UI Subtitle Panel" to the Custom Subtitle Panel field.
    The Dialogue System Extras page has an example scene (direct download). The example scene is in 2D. If you've haven't enabled 2D support in the Dialogue System, please do that before playing the example scene. The same steps apply to 3D.
     
    Froghuto likes this.
  44. Froghuto

    Froghuto

    Joined:
    Oct 4, 2012
    Posts:
    61
    That works perfectly thanks for your help!
    One more thing, what would be the best way to have a special dialogue UI for specific conversations (other conversations involving the same Actors should have a different UI)? Is there a pre-made workflow for this or should/could I use DialogueManager.UseDialogueUI()?
     
  45. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    There's no pre-made workflow, although there's an item on the roadmap to let you assign a dialogue UI to a Dialogue System Trigger. Please use DialogueManager.UseDialogueUI() before starting the specific conversation.
     
    Froghuto likes this.
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Chat Mapper XML Export Patch Available

    In addition to its full-featured built-in editor, the Dialogue System can import and export several formats, including articy:draft, Ink, TalkIt, CSV, Aurora (Neverwinter Nights), and Chat Mapper.

    The Dialogue System Extras page has a patch that updates the Chat Mapper XML update format for compatibility with import into Chat Mapper 1.9.10.0+. (This update will also be in the upcoming version 2.2.3.)
     
  47. Froghuto

    Froghuto

    Joined:
    Oct 4, 2012
    Posts:
    61
    When using Cinemachine is it possible to combine this with Sequencer Camera Angles (i.e. the Camera() sequencer command) so a cinemachine camera is created/activated at the predefined angle setting to take advantage of all cinemachine blending features etc? Or would I need to create custom sequencer commands to handle this?
     
  48. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Hi @Froghuto - You'll want to write a custom sequencer command or use the built-in CinemachinePriority() sequencer command.
     
    Froghuto likes this.
  49. huntersteeger

    huntersteeger

    Joined:
    Dec 27, 2017
    Posts:
    19
    Hi, I'm using Dialogue System to run a lot of my game's systems. I was wondering how I can show certain variables I have made in the system and show them, in my character's inventory, and have them update in realtime. For example, I use a variable to keep track of my player's money. I'd like the player to be able to check how much they have at any given time. Also, I want to implement a system where the player can look at notes they have found in my game world at any time.
     
  50. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Hi @huntersteeger - To get a variable's value in your own scripts, use DialogueLua.GetVariable:
    Code (csharp):
    1. using PixelCrushers.DialogueSystem;
    2. ...
    3. int money = DialogueLua.GetVariable("Money").asInt;
    If you want to update it in realtime after changing the Money variable in a dialogue entry node's Script field, you can register a small C# method (e.g., "MoneyChanged()") with Lua and use it in the same Script field. For example, the Script field might look like:
    • Script: Variable["Money"] = Variable["Money"] + 5; MoneyChanged();
    Your C# method might look like this:
    Code (csharp):
    1. void MoneyChanged()
    2. {
    3.     moneyUIText.text = DialogueLua.GetVariable("Money").asString;
    4. }
    ---

    For your note system, you can use the Item[] table. To add a note, add an item in the Dialogue Editor's Quests/Items section. Put the note's text in the Description field. Add a custom Boolean field "Found" to the items. When the player finds a note, set the Found field true using the "..." dropdown in a dialogue entry node's Script field, or DialogueLua.SetItemField() in a C# script:
    Code (csharp):
    1. DialogueLua.SetItemField("Heist Plans", "Found", true);
    To get the list of notes that the player has found:
    Code (csharp):
    1. List<string> notesFound = new List<string>();
    2. foreach (var item in DialogueManager.masterDatabase.items)
    3. {
    4.     if (item.IsItem && item.LookupBool("Found"))
    5.     {
    6.         notesFound.Add(item.Name);
    7.     }
    8. }
    When the player chooses a note from the list, you can retrieve the text straight from the database; no need to get it from Lua unless it can change at runtime:
    Code (csharp):
    1. string noteText = DialogueManager.masterDatabase.GetItem("Heist Plans").Description;
     
    huntersteeger likes this.