Adventure Creator Integration with Ink Integration

Announcements, support questions, and discussion for the Dialogue System.
some_name
Posts: 6
Joined: Tue Sep 27, 2022 6:14 pm

Adventure Creator Integration with Ink Integration

Post by some_name »

Hi there! This is my first post, so feel free to correct me wherever necessary.

I am using Dialogue System with the Ink integration and Adventure Creator. What works: accessing AC variables in Dialogue Manager and vice versa. What doesn't work: using the Lua functions provided by the AdventureCreatorBridge as EXTERNAL functions within ink scripts.

Which makes complete sense, because those functions are not bound as an external function in the Ink integration script. I tried to bind them like this (at line 719 of DialogueSystemInkIntegration):

Code: Select all

var bridge = DialogueManager.Instance.GetComponent<AdventureCreatorBridge>();
story.BindExternalFunction("acGetItemCount", (string itemName) => { return bridge.acGetItemCount(itemName).asInt; });
This does seem to be sound. The problem arises when trying to import the Adventure Creator Support namespace like this:

Code: Select all

using PixelCrushers.DialogueSystem.AdventureCreatorSupport;
I get the following error:
Assets\Plugins\Pixel Crushers\Dialogue System\Third Party Support\Ink Support\Scripts\DialogueSystemInkIntegration.cs(7,36): error CS0234: The type or namespace name 'AdventureCreatorSupport' does not exist in the namespace 'PixelCrushers.DialogueSystem' (are you missing an assembly reference?)
I did some investigation and it seems to me that there are two overlapping namespaces called PixelCrushers.DialogueSystem (one points to Assets/Pixel Crushers/Dialogue System and the other to Assets/Plugins/Pixel Crushers/Dialogue System).

Is there an easy fix?

Just FYI I am a Software Developer by trade but very new to C# and Unity. So this whole problem might stem from my missing familarity with C# or Units or package.

Thanks in advance!
User avatar
Tony Li
Posts: 21970
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adventure Creator Integration with Ink Integration

Post by Tony Li »

Hi,

You're really close. Instead of directly modifying the DialogueSystemInkIntegration class, make a subclass. Put that subclass in your own folder, outside of the Plugins folder. Unity compiles scripts inside Plugins first, without visibilty to scripts that are outside Plugins. Then it compiles scripts that are outside Plugins in a separate pass that has visibility into the compiled code of the Plugins folder.
some_name
Posts: 6
Joined: Tue Sep 27, 2022 6:14 pm

Re: Adventure Creator Integration with Ink Integration

Post by some_name »

Thanks Toni! This helped me, everything works. Just for future reference (somebody might have a similar problem), I created a subclass like this:

Code: Select all

using UnityEngine;
using UnityEngine.Serialization;
using System.Collections.Generic;
using Ink.Runtime;
using System.Collections;
using PixelCrushers.DialogueSystem.AdventureCreatorSupport;

namespace PixelCrushers.DialogueSystem.InkSupport
{

    /// <summary>
    /// Integrates Ink with the Dialogue System. In this integration, Ink does the
    /// processing, and the Dialogue System does the UI and handles triggers. It
    /// also handles saving/loading and exposes functions to manage quests and
    /// show alerts.
    /// </summary>
    [AddComponentMenu("Pixel Crushers/Dialogue System/Third Party Support/Ink/Dialogue System Ink Integration")]
    public class DialogueSystemInkIntegrationAC : DialogueSystemInkIntegration
    {
        #region External Functions

        protected override void BindExternalFunctions(Story story)
        {
            base.BindExternalFunctions(story);
                      
            // AC functions
            story.BindExternalFunction("acGetItemCount", (string itemName) => { return AdventureCreatorBridge.acGetItemCount(itemName); });
        }

        protected override void UnbindExternalFunctions(Story story)
        {
            base.UnbindExternalFunctions(story);

            // AC functions
            story.UnbindExternalFunction("acGetItemCount");
        }

        #endregion

    }
}
User avatar
Tony Li
Posts: 21970
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adventure Creator Integration with Ink Integration

Post by Tony Li »

Thanks for sharing the script!
some_name
Posts: 6
Joined: Tue Sep 27, 2022 6:14 pm

Re: Adventure Creator Integration with Ink Integration

Post by some_name »

Very weird behaviour: yesterday everything worked, but today it doesn't find the ink conversation if I use the subclass I created (works well with the original class though). I use this subclass:

Code: Select all

using UnityEngine;
using UnityEngine.Serialization;
using System.Collections.Generic;
using Ink.Runtime;
using System.Collections;
using PixelCrushers.DialogueSystem.AdventureCreatorSupport;

namespace PixelCrushers.DialogueSystem.InkSupport
{
    public class DialogueSystemInkIntegrationAC : DialogueSystemInkIntegration
    {
        #region External Functions

        protected override void BindExternalFunctions(Story story)
        {
            base.BindExternalFunctions(story);
                      
            // AC functions
            story.BindExternalFunction("acGetItemCount", (string itemName) => { return AdventureCreatorBridge.acGetItemCount(itemName); });
            story.BindExternalFunction("acSetItemCount", (string itemName, int value) => { AdventureCreatorBridge.acSetItemCount(itemName, value); });
        }

        protected override void UnbindExternalFunctions(Story story)
        {
            base.UnbindExternalFunctions(story);

            // AC functions
            story.UnbindExternalFunction("acGetItemCount");
            story.UnbindExternalFunction("acSetItemCount");
        }

        #endregion

    }
}
Do you have any idea why this is? I added the conversation to my InkIntegration subclass via the menu like this:

Image
User avatar
Tony Li
Posts: 21970
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adventure Creator Integration with Ink Integration

Post by Tony Li »

Are there any warnings or errors in the Console window? (Make sure the Console window isn't hiding warnings or errors.)
some_name
Posts: 6
Joined: Tue Sep 27, 2022 6:14 pm

Re: Adventure Creator Integration with Ink Integration

Post by some_name »

Only this one, if I trigger the conversation via AC's action list:
Dialogue System: Conversation 'easy_conv' not found in database.
UnityEngine.Debug:LogWarning (object)
PixelCrushers.DialogueSystem.ConversationModel:.ctor (PixelCrushers.DialogueSystem.DialogueDatabase,string,UnityEngine.Transform,UnityEngine.Transform,bool,PixelCrushers.DialogueSystem.IsDialogueEntryValidDelegate,int,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Model/ConversationModel.cs:151)
PixelCrushers.DialogueSystem.DialogueSystemController:StartConversation (string,UnityEngine.Transform,UnityEngine.Transform,int) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueSystemController.cs:947)
PixelCrushers.DialogueSystem.DialogueSystemController:StartConversation (string,UnityEngine.Transform,UnityEngine.Transform) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueSystemController.cs:1021)
Last edited by some_name on Thu Sep 29, 2022 5:40 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 21970
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adventure Creator Integration with Ink Integration

Post by Tony Li »

Is it possible that the game is using a different Dialogue Manager (e.g., one that survived from an earlier scene) that doesn't have easy_conv?
some_name
Posts: 6
Joined: Tue Sep 27, 2022 6:14 pm

Re: Adventure Creator Integration with Ink Integration

Post by some_name »

I use only a single scene and a single DialogueManager with the attached script as seen on my previous post. I am very puzzled because it worked yesterday and since then I didn't make any changes (that I am aware of atleast...).
User avatar
Tony Li
Posts: 21970
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adventure Creator Integration with Ink Integration

Post by Tony Li »

I can't think of why it works with the original script but not your subclass.

Please tick your script's Debug checkbox. Then play the scene and verify that the Console has lines like this:

Code: Select all

Dialogue System: Loading Ink story easy_conv
Create conversation [#] easy_conv
Also, feel free to send a reproduction project to tony (at) pixelcrushers.com if you'd like me to take a direct look in the morning. (I'm finishing up work for the night now.)
Post Reply