Yarn 1.2.7

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

Re: Yarn 1.2.7

Post by gblekkenhorst »

Right, I forgot, the last package made the Run Node work weird,,,, i thought it was freezing the conversation, but it turns out if I hit the interact button again it will continue to the next conversation. I can also manually add the Continue() sequence to the run node and it fixes it.

yield return new WaitForSeconds(time); throws an error that it can't convert double to float (int is fine though?)
User avatar
Tony Li
Posts: 21050
Joined: Thu Jul 18, 2013 1:27 pm

Re: Yarn 1.2.7

Post by Tony Li »

Try this version:

Code: Select all

public void Pause(double time)
{
    StartCoroutine(StartWait((int)time));
}

I'll let you know what I find out about the Run Node.
gblekkenhorst
Posts: 78
Joined: Wed Jun 24, 2020 5:06 pm

Re: Yarn 1.2.7

Post by gblekkenhorst »

That worked! Thanks!
gblekkenhorst
Posts: 78
Joined: Wed Jun 24, 2020 5:06 pm

Re: Yarn 1.2.7

Post by gblekkenhorst »

I'm trying to make a command that adds quests ands then another that updates the quest state, but I'm not sure why it's not working?

Code: Select all

<<addQuest "paperQuest" "..." "..." "...">>
<<questState {"paperQuest"} "active">>

Code: Select all

 public void AddQuest(string questName, string desc, string succ, string failure)
    {
        QuestLog.AddQuest(questName, desc, succ, failure, PixelCrushers.DialogueSystem.QuestState.Unassigned);
        
        
        Debug.Log(questName + " should be " + QuestLog.CurrentQuestState(questName) + " " + QuestLog.GetQuestDescription(questName));  // this doesn't print at all

        
        Debug.Log(QuestLog.GetAllQuests());
    }

        public void QuestState(string questName, string stateString)
    {

        //QuestState.Active, QuestState.Unassigned, QuestState.Success
        if (stateString == "unassigned")
            state = PixelCrushers.DialogueSystem.QuestState.Unassigned;         
        else if (stateString == "active")
            state = PixelCrushers.DialogueSystem.QuestState.Active;
        else if (stateString == "sucess")
            state = PixelCrushers.DialogueSystem.QuestState.Success;
        else if (stateString == "fail")
            state = PixelCrushers.DialogueSystem.QuestState.Failure;
        else
            state = PixelCrushers.DialogueSystem.QuestState.Unassigned;
       
        
        QuestLog.SetQuestState(questName, state);
        Debug.Log(questName + " should be " + QuestLog.CurrentQuestState(questName)); // this prints, but doesn't show the quest state
    }
User avatar
Tony Li
Posts: 21050
Joined: Thu Jul 18, 2013 1:27 pm

Re: Yarn 1.2.7

Post by Tony Li »

Hi,

Please try this patch. I think it should address both issues.

(see later post)
gblekkenhorst
Posts: 78
Joined: Wed Jun 24, 2020 5:06 pm

Re: Yarn 1.2.7

Post by gblekkenhorst »

I think this overwrote something with the pause command? I am getting this again:

Code: Select all

ArgumentException: Object of type 'System.String' cannot be converted to type 'System.Double'.

Dialogue System: Lua code '_G['pause']('1')
' threw exception 'Object of type 'System.String' cannot be converted to type 'System.Double'.'
My quests function works, but only if the strings passed are a single word. Maybe I'm just formatting this wrong - I've tried it with and without the curly brackets.

Code: Select all

Dialogue System: Lua code 'local run_cmd_args = EvaluateYarnExpression({ 'Hit 'Q' to toggle your MP3 player.' })
_G['alert'](run_cmd_args[1])
' threw exception 'Code has syntax errors:
Line 1, Col 45 '{': Failed to parse Expr of GroupExpr.
Line 1, Col 44 '(': Failed to parse Letter of Name.
Line 1, Col 44 '(': Failed to parse Name of VarName.
Line 1, Col 44 '(': Failed to parse 'nil' of NilLiteral.
Line 1, Col 44 '(': Failed to parse Text of BoolLiteral.
Line 1, Col 44 '(': Failed to parse '0'...'9' of Digit.
Line 1, Col 44 '(': Failed to parse (Digit)+ of FloatNumber.
Line 1, Col 44 '(': Failed to parse Name of VariableArg.
Line 1, Col 44 '(': Failed to parse firstTerm of OperatorExpr.
Line 1, Col 44 '(': Failed to parse Expr of ExprStmt.
Line 1, Col 44 '(': Failed to parse remaining input.

Code: Select all

Dialogue System: Lua code 'local run_cmd_args = EvaluateYarnExpression({ 'Deliver papers for Zane's paper route.', 'You've delivered all of the papers!', 'You missed the deadline and Zane's customers are upset with you both.' })
_G['addQuest']("paperQuest", run_cmd_args[1], run_cmd_args[2], run_cmd_args[3])
' threw exception 'Code has syntax errors:
Line 1, Col 45 '{': Failed to parse Expr of GroupExpr.
Line 1, Col 44 '(': Failed to parse Letter of Name.
Line 1, Col 44 '(': Failed to parse Name of VarName.
Line 1, Col 44 '(': Failed to parse 'nil' of NilLiteral.
Line 1, Col 44 '(': Failed to parse Text of BoolLiteral.
Line 1, Col 44 '(': Failed to parse '0'...'9' of Digit.
Line 1, Col 44 '(': Failed to parse (Digit)+ of FloatNumber.
Line 1, Col 44 '(': Failed to parse Name of VariableArg.
Line 1, Col 44 '(': Failed to parse firstTerm of OperatorExpr.
Line 1, Col 44 '(': Failed to parse Expr of ExprStmt.
Line 1, Col 44 '(': Failed to parse remaining input.
It's also still doing the pause on Run Nodes.

Is there a way to set the quest display name by script?

Totally forgot to mention, looks like the function execution problem is fixed! They now only go off when the right branch is selected.
Last edited by gblekkenhorst on Tue Oct 11, 2022 10:03 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 21050
Joined: Thu Jul 18, 2013 1:27 pm

Re: Yarn 1.2.7

Post by Tony Li »

Typo. All fixed:

DS_YarnPatch_2022-10-11a.unitypackage
gblekkenhorst wrote: Tue Oct 11, 2022 7:24 pmIs there a way to set the quest display name by script?
Yes. Use DialogueLua.SetQuestField(). For example, if you have a quest whose Name is "KillRatsQuest", you can set the display name to "Mr. Baker's Rat Problem" like this:

Code: Select all

DialogueLua.SetQuestField("KillRatsQuest", "Display Name", "Mr. Baker's Rat Problem");
gblekkenhorst
Posts: 78
Joined: Wed Jun 24, 2020 5:06 pm

Re: Yarn 1.2.7

Post by gblekkenhorst »

Still some errors:

This is my yarn:

Code: Select all

Thought: Alrighty. If I want to get this old car fixed up, I'm going to have to earn some money. 
<<set $carFundLeft to $carFundTotal - $carFund>>
Thought: I'm SO close, just ${$carFundLeft} to go - a few gigs should do it.
Thought: Better check my MP3 player is juiced up before I head out.
<<bringUpMP3>>
<<pause 2>>
Thought: Looks good! I got some new stuff on here, I'm excited to check out the new playlists. 
<<alert {"Hit 'Q' to open and close your MP3 player"}>>
<<alert "Hit 'Q' to open and close your MP3 player">>
//<<addQuest "paperQuest" "Extra Extra" "Deliver papers for Zane's paper route." "You've delivered all of the papers!" "You missed the deadline and Zane's customers are upset with you both.">>
Here's what I'm getting:

{$carFundLeft} is just printing as {$0}. This started before 10-11a, I noticed it in our build last night before I added it.

pause works great!

alert 1:

Code: Select all

Dialogue System: Lua code 'local run_cmd_args = EvaluateYarnExpression({ 'Hit 'Q' to open and close your MP3 player' })
_G['alert'](run_cmd_args[1])
' threw exception 'Code has syntax errors:
Line 1, Col 45 '{': Failed to parse Expr of GroupExpr.
Line 1, Col 44 '(': Failed to parse Letter of Name.
Line 1, Col 44 '(': Failed to parse Name of VarName.
Line 1, Col 44 '(': Failed to parse 'nil' of NilLiteral.
Line 1, Col 44 '(': Failed to parse Text of BoolLiteral.
Line 1, Col 44 '(': Failed to parse '0'...'9' of Digit.
Line 1, Col 44 '(': Failed to parse (Digit)+ of FloatNumber.
Line 1, Col 44 '(': Failed to parse Name of VariableArg.
Line 1, Col 44 '(': Failed to parse firstTerm of OperatorExpr.
Line 1, Col 44 '(': Failed to parse Expr of ExprStmt.
Line 1, Col 44 '(': Failed to parse remaining input.
'
UnityEngine.Debug:LogError (object)
PixelCrushers.DialogueSystem.Lua:RunRaw (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:228)
PixelCrushers.DialogueSystem.Lua:Run (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:129)
PixelCrushers.DialogueSystem.ConversationModel:GetState (PixelCrushers.DialogueSystem.DialogueEntry,bool,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Model/ConversationModel.cs:234)
PixelCrushers.DialogueSystem.ConversationModel:GetState (PixelCrushers.DialogueSystem.DialogueEntry) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Model/ConversationModel.cs:304)
PixelCrushers.DialogueSystem.ConversationController:OnFinishedSubtitle (object,System.EventArgs) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:270)
PixelCrushers.DialogueSystem.ConversationView:FinishSubtitle () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:428)
PixelCrushers.DialogueSystem.ConversationView:HandleContinueButtonClick () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:400)
PixelCrushers.DialogueSystem.ConversationView:OnConversationContinue (PixelCrushers.DialogueSystem.IDialogueUI) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:383)
PixelCrushers.DialogueSystem.AbstractDialogueUI:OnContinueConversation () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/UI/Abstract/Dialogue/AbstractDialogueUI.cs:366)
PixelCrushers.DialogueSystem.AbstractDialogueUI:OnContinue () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/UI/Abstract/Dialogue/AbstractDialogueUI.cs:356)
PixelCrushers.DialogueSystem.StandardUIContinueButtonFastForward:OnFastForward () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/UI/Standard/Effects/StandardUIContinueButtonFastForward.cs:75)
UnityEngine.EventSystems.EventSystem:Update () (at C:/Program Files/UnityEditors/2020.2.6f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:385)
Alert 2 I'm obviously coding wrong, just wanted to check

Code: Select all

Dialogue System: Lua code '_G['alert'](' "', 'Hit', 'Q', 'to', 'open', 'and', 'close', 'your', 'MP3', 'player', '"')
' threw exception 'Number of parameters specified does not match the expected number.'
UnityEngine.Debug:LogError (object)

I also added some stuff to YarnConverter.cs that I think are helpful!

And the RUN nodes don't have the continue sequence they're presenting as an invisible dialogue box, but I figured out how to fix it! I added this to 1111:

Code: Select all

dlgEntry.Sequence = EntrySequence.ContinueDialogue; 
I added in some code at 1032 to be able to access some of the Sequencer commands from Yarn

Code: Select all

 else if (cmdName == "seq")
                    {
                        var dlgEntry = CreateDialogueEntry(conversation, title, desc);
                        var cmdType = cmdTokens.Length > 1 ? cmdTokens[1] : "0";
                        var cmdTypeString = "";

                        switch (cmdType)
                        {
                            case "LookAt":
                                cmdTypeString = "LookAt(" + cmdTokens[2] + "," + cmdTokens[3] + ");\n Continue();";
                                break;
                            case "SetActive": // only works to disable 
                                cmdTypeString = "SetActive(" + cmdTokens[2] + "," + cmdTokens[3] + "); \n Continue();";
                                break;
                            default:
                                cmdTypeString = "";
                                break;
                        }

                        if (cmdTypeString != "") 
                        { 
                        dlgEntry.Sequence = String.Format(cmdTypeString);
                            dlgEntry.Title = "Run " + cmdType;
                            basicStmt.AddDialogueEntry(dlgEntry);
                        }
                    }
this is accessible through calling

Code: Select all

<<seq LookAt Car Zane>>
<<seq SetActive Zane false>>
I tried doing ShowAlert, but I couldn't do it because I haven't figured out how to pass a string from Yarn. You can't set active to true, even though Zane is not involved in this conversation. I think the sequences are still useful!
User avatar
Tony Li
Posts: 21050
Joined: Thu Jul 18, 2013 1:27 pm

Re: Yarn 1.2.7

Post by Tony Li »

> {$carFundLeft} is just printing as {$0}. This started before 10-11a, I noticed it in our build last night before I added it.

I'll check this.


> alert 1:
> Alert 2 I'm obviously coding wrong, just wanted to check


Am I understanding Yarn wrong, or is Alert 2 the correct Yarn syntax?

The bug in the Yarn importer is that it's not properly handling the embedded single quotes in:

"Hit 'Q' to open and close your MP3 player"


>And the RUN nodes don't have the continue sequence they're presenting as an invisible dialogue box, but I figured out how to fix it! I added this to 1111:</b>

Code: Select all

dlgEntry.Sequence = EntrySequence.ContinueDialogue; 
I'll add that.

> I added in some code at 1032 to be able to access some of the Sequencer commands from Yarn

That's a good idea! What if we do it like this instead:

<<seq "LookAt(Car, Zane)" >>
<<seq "SetActive(Zane, false)"e>>

This way we won't have to write importer code for each sequencer command, and it will work even for your own custom sequencer commands and any sequencer commands added by third party integrations.

I'll plan to have a patch to address these issues by end of day tomorrow.
User avatar
Tony Li
Posts: 21050
Joined: Thu Jul 18, 2013 1:27 pm

Re: Yarn 1.2.7

Post by Tony Li »

I running late on this. It will be my priority tomorrow morning.
Post Reply