Page 1 of 1

Updating an Adventue Creator Inventory before Ending the Conversation

Posted: Wed Jul 29, 2020 6:35 pm
by CodePrincess
Evening, everybody!

So, Sis is loving this [item name].Count approach for updating an Adventure Creator inventory; It's so easy!

I was just wondering, is there a way to have the added item show up in the inventory before the conversation ends?

I'm using 1.71.7, Unity 2019.4.0f1 and Pixel Crushers' Dialogue System for Unity v 2.2.7, if that helps.

Thank you for your time and three cheers for Pixel Crushers! :-D

Re: Updating an Adventue Creator Inventory before Ending the Conversation

Posted: Wed Jul 29, 2020 8:50 pm
by Tony Li
Hi!

The Dialogue System Extras page has an updated Adventure Creator integration package. It's in the "Updated for 2.2.8" foldout, but it works fine with 2.2.7. The "Updated with 2.2.8" wording just means that it was updated after 2.2.8 was released.

The updated package adds two Lua functions: SyncACToLua() and SyncLuaToAC(). You can use SyncLuaToAC() to have the added item show up in the AC inventory before the conversation ends. To add the Lua function, click the Script field's "..." menu and select Custom > AC > SyncLuaToAC. Then click Apply. Or just type "SyncLuaToAC()" manually into the Script field.

Re: Updating an Adventue Creator Inventory before Ending the Conversation

Posted: Thu Jul 30, 2020 12:51 am
by CodePrincess
Oh, perfect! :D

It's... saying the Lua commands haven't been registered?

I tried faking a script for that, but it didn't seem to take.

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DialogueACUpdateCommands : MonoBehaviour
{
    private void OnEnable()
    {
        PixelCrushers.DialogueSystem.Lua.RegisterFunction("SyncACToLua", this, typeof(
            DialogueAnimatedGifCommands).GetMethod("SyncACToLua")); // orig. typeof(GifManager)
        PixelCrushers.DialogueSystem.Lua.RegisterFunction("SyncLuaToAC", this, typeof(
           DialogueAnimatedGifCommands).GetMethod("SyncLuaToAC"));
    }

    private void OnDisable()
    {
        PixelCrushers.DialogueSystem.Lua.UnregisterFunction("SyncACToLua");
        PixelCrushers.DialogueSystem.Lua.UnregisterFunction("SyncLuaToAC");
    }
}
What do you think I should try next?

Re: Updating an Adventue Creator Inventory before Ending the Conversation

Posted: Thu Jul 30, 2020 9:53 am
by Tony Li
Hi,

Does your AdventureCreatorBridge component contain an Awake method that looks like this?

Code: Select all

private void Awake()
{
    if (!areLuaFunctionsRegistered)
    {
        areLuaFunctionsRegistered = true;
        Lua.RegisterFunction("SyncACToLua", this, SymbolExtensions.GetMethodInfo(() => SyncAdventureCreatorToLua()));
        Lua.RegisterFunction("SyncLuaToAC", this, SymbolExtensions.GetMethodInfo(() => SyncLuaToAdventureCreator()));
    }
}
If not, please try importing DS_AdventureCreatorSupport_2020-07-29.unitypackage again.

Re: Updating an Adventue Creator Inventory before Ending the Conversation

Posted: Thu Jul 30, 2020 10:14 am
by CodePrincess
Private Awake() wasn't in there. Should I add the script you posted?

Re: Updating an Adventue Creator Inventory before Ending the Conversation

Posted: Thu Jul 30, 2020 10:20 am
by Tony Li
Yes, please download that unitypackage and import it. It contains an updated bridge script that contains that Awake method.

Re: Updating an Adventue Creator Inventory before Ending the Conversation

Posted: Thu Jul 30, 2020 10:39 am
by CodePrincess
If not, please try importing DS_AdventureCreatorSupport_2020-07-29.unitypackage again.
...How'd I miss that line. How embarrassing.

Okay, I'm downloading the unity package... and everything fixed!
Thank you so much!
Have a good day, Tony!

Re: Updating an Adventue Creator Inventory before Ending the Conversation

Posted: Thu Jul 30, 2020 10:49 am
by Tony Li
You too!