Add conversation action through script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Dralks
Posts: 44
Joined: Mon May 24, 2021 6:19 pm

Add conversation action through script

Post by Dralks »

This is my third question, my heart hurts a little every time I need to ask something, you are amazing Tony but I can only imagine how busy you are answering so many messages, thank you for the amazing customer service!

I'm doing some Automation and I need to get my script to add a conversation action automatically, so basically I need it to have the same effect of pressing "Add action" and selecting "Start Conversation" in the conversation trigger, I have everything else up and running and it works fine, just can't figure out how to get an action to work, if it helps the code that I'm missing would be replacing this comment:

Code: Select all

        private void PrepareCollectableDialog()
        {
            DialogSystem = GetComponent<DialogueSystemTrigger>();
            CollectableActor = DialogueManager.masterDatabase.actors.SingleOrDefault(x => x.Name == InterfaceName.COLLECTABLE_ACTOR);
            CollectableConversation = DialogueManager.masterDatabase.conversations.First(x => x.ActorID == CollectableActor.id);
            DialogSystem.trigger = DialogueSystemTriggerEvent.OnUse;
            //Here I need to add a 'start conversation' so I don't need to do it manually
            DialogSystem.conversation = CollectableConversation.Title;
        }
User avatar
Tony Li
Posts: 22162
Joined: Thu Jul 18, 2013 1:27 pm

Re: Add conversation action through script

Post by Tony Li »

Hi,

As long as you set the DialogueSystemTrigger's conversation value, it will try to start a conversation. You don't have to do anything else to set it up as a new action. You may also want to set DialogueSystemTrigger.conversationActor and conversationConversant, and/or any other variables normally shown in the Actions > Start Conversation section. Otherwise they'll use the default values you see when you manually select Add Action > Start Conversation.
Post Reply