Yarn 1.2.7

Announcements, support questions, and discussion for the Dialogue System.
gblekkenhorst
Posts: 81
Joined: Wed Jun 24, 2020 5:06 pm

Re: Yarn 1.2.7

Post by gblekkenhorst »

This overwrote the merge button, which I couldn't actually get working yet. I'm trying to figure out how to import updates to the script without overwriting certain nodes - like the hub, and some other nodes that I have scene events hooked up to. I haven't been able to test the new merge button because I've broken my script in some way I haven't been able to solve yet :lol:

I get the following error a lot. I've figured out that it means it can't find a node I'm linking to - it came up when I was trying to merge because I was trying to bring in scripts that only had the updated nodes in it, and couldn't find the hub. But it's also happening when I bring in scripts with bad whitespace. Is there a way to have this throw a debug error telling me which node it failed to find, or which node the failure happened in?

Code: Select all

KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
PixelCrushers.DialogueSystem.Yarn.YarnConverter.ResolveDialogueEntryLinks (PixelCrushers.DialogueSystem.Yarn.BlockStatement block, PixelCrushers.DialogueSystem.DialogueEntry previousEntry) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Editor/Tools/Importers/Yarn/YarnConverter.cs:547)
User avatar
Tony Li
Posts: 21948
Joined: Thu Jul 18, 2013 1:27 pm

Re: Yarn 1.2.7

Post by Tony Li »

Hi,

The merge feature hadn't been fully implemented yet, so we went ahead and turned it into a merge variables feature which leaves existing variables in your dialogue database intact (i.e., won't change the Initial Values you have set).

The Yarn importer assumes that all other content comes straight from Yarn, so you shouldn't make changes to conversations in the Dialogue Editor. They'll be lost the next time you import from Yarn.

If you need to use scene events, you may prefer to write your content in the Dialogue System's built-in Dialogue Editor instead.

Or, if you use Yarn, you could implement custom Yarn commands to do what you would otherwise do with scene events.
gblekkenhorst
Posts: 81
Joined: Wed Jun 24, 2020 5:06 pm

Re: Yarn 1.2.7

Post by gblekkenhorst »

Whatever I point Custom Commands File at RollerGirlYarnCommands.cs in the Yarn Importer, it gets overwritten with a script that has this comment at the top:

Code: Select all

// WARNING: Do not modify this file. It is automatically generated on every Yarn project import.
//          To add/change behavior, make a subclass of RollerGirlYarnCommands.
//          Generated on: 2022-09-22 3:25:52 PM

So I made a subclass that looks like this. This is what my custom command file looks like, basically copied from the wiki:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem.Yarn;
using PixelCrushers.DialogueSystem;

public class RollerGirlCustomCommandsNew : RollerGirlYarnCommands
{

    public override void RegisterFunctions()
    {
        // This MUST be called here:
        base.RegisterFunctions();

        Lua.RegisterFunction("my_command", this, SymbolExtensions.GetMethodInfo(() => MyCustomCommand("", 0f, false)));
    }

    public override void UnregisterFunctions()
    {
        // This MUST be called here:
        base.UnregisterFunctions();

        Lua.UnregisterFunction("my_command");
    }


    public void MyCustomCommand(string arg1, float arg2, bool arg3)
    {
        Debug.Log($"MyCustomCommand('{arg1}', {arg2}, {arg3}) - SUCCESS");
    }
}

This is the error I get when the dialogue hits that command:

Code: Select all

Dialogue System: Lua code '_G['my_command']('arg1', 'arg2', 'arg3')
' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
So it's not seeing the command. Am I missing a step?
gblekkenhorst
Posts: 81
Joined: Wed Jun 24, 2020 5:06 pm

Re: Yarn 1.2.7

Post by gblekkenhorst »

Also: The conditional format you suggested for the hub worked great!

There are big pauses in the conversation - it looks like every time there is a <Run Node > node, it pauses for a beat before continuing.

I fixed it by adding this line to YarnConverter.cs line 1099, if this helps anyone else.

Code: Select all

dlgEntry.Sequence = EntrySequence.ContinueDialogue;
User avatar
Tony Li
Posts: 21948
Joined: Thu Jul 18, 2013 1:27 pm

Re: Yarn 1.2.7

Post by Tony Li »

Hi,

Creating a subclass script RollerGirlCustomCommandsNew is exactly the right thing to do.

Did you add your RollerGirlCustomCommandsNew script to the Dialogue Manager GameObject?

Your custom command doesn't need to be named "my_command". That's just an example name for the manual.

Good thinking on the RunNode. I'll add that in the next release.
gblekkenhorst
Posts: 81
Joined: Wed Jun 24, 2020 5:06 pm

Re: Yarn 1.2.7

Post by gblekkenhorst »

Oh, I didn't see about adding it to the editor in the documentation you linked! Now that it's attached, I'm getting a different error:

Code: Select all

ArgumentException: Object of type 'System.String' cannot be converted to type 'System.Single'.
System.RuntimeType.CheckValue (System.Object value, System.Reflection.Binder binder, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Reflection.MonoMethod.ConvertValues (System.Reflection.Binder binder, System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
Language.Lua.LuaMethodFunction.InvokeMethod (Language.Lua.LuaValue[] args) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Interpreter/LuaValue/LuaMethodFunction.cs:35)
UnityEngine.Debug:LogException(Exception)
....
I get this even if I switch the command to only take a float and print it to the debug log. Edit: The command works just fine so long as I don't use arguements!

(I'm just using my_command to try to get it working as is before I start customizing it.)
gblekkenhorst
Posts: 81
Joined: Wed Jun 24, 2020 5:06 pm

Re: Yarn 1.2.7

Post by gblekkenhorst »

I'm also running into an issue where the command is executing even if that dialogue branch isn't selected. Here is my yarn file:

Code: Select all

title: Items/Crockpot/BetweenChillis
position: -10,-297
---
Thought: Here's Debbie's other crockpot. Not looking forward to skating around with this guy.
    -> Naomi: Might as well get on with it.
        <<wait 1>>
        <<set $chilliQuest to 3>>
        <<GetEmptyCrockPot>>
    -> Naomi: I'm just going to take a quick breather and come back later.
===
GetEmptyCrockPot should only execute if "Might as well get on with it" is selected, but it fires even if you select "I'm just going to take a quick breather and come back later."
User avatar
Tony Li
Posts: 21948
Joined: Thu Jul 18, 2013 1:27 pm

Re: Yarn 1.2.7

Post by Tony Li »

When you were passing arguments to your command, were you passing a string, float, and bool (in that order)?

I'm researching the second issue. I'll get back to you on it.
gblekkenhorst
Posts: 81
Joined: Wed Jun 24, 2020 5:06 pm

Re: Yarn 1.2.7

Post by gblekkenhorst »

I tried it as-is, string, float, bool, I sent the command as <<my_command "this is a string" 0f false>>

I also tried editing the function and registration to be just a string and just a bool and just a float - none of them worked. Even just the float and just the bool resulted in the ''System.String' cannot be converted to type 'System.Single'.' message.

Thank you so much for all your help with this! I use DS for a lot of different projects, as you've probably noticed. Using the Yarn integration for this one is SO GREAT, writing scripts in Yarn is so naturalistic and makes it so easy to share the script with the client before integrating it into the game!
User avatar
Tony Li
Posts: 21948
Joined: Thu Jul 18, 2013 1:27 pm

Re: Yarn 1.2.7

Post by Tony Li »

I'll have to research this one, too, and get back to you by the end of the weekend (hopefully sooner).

Thanks for your patience with the Yarn integration. Yarn's a useful format, but it's a tough one to integrate. We'll get there, though!
Post Reply