Checking an int during conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Frank11
Posts: 4
Joined: Thu Sep 01, 2022 6:52 pm

Checking an int during conversation

Post by Frank11 »

Hey and thanks again for the Dialogue System, it is a truly inspiring asset.

I was hoping for some advice, if possible.

I have an int called moonCount which i have registered to Lua as a double (the script is attached to the player gameObject)

Code: Select all

    public double CurrentMoonsForDialogueSystem()
    {
        return moonCount;
    }
    
        private void OnEnable()
    {
        Lua.RegisterFunction(nameof(CurrentMoonsForDialogueSystem), this, SymbolExtensions.GetMethodInfo(() => CurrentMoonsForDialogueSystem()));
    }
    

I have a simple conversation that asks the player their moon count.

I want to check the moonCount of the player and if it is less than a certain number it will say "Not Enough Moons" and if its greater or equal to that number it will say "You have enough moons". (The number would depend on the scene the player is in)

Basically i'm having trouble putting this logic into the conversation, I think I have to make a bool? But I'm struggling with the Lua part of it, any advice would be greatly appreciated!
Attachments
convo.png
convo.png (16.64 KiB) Viewed 197 times
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Checking an int during conversation

Post by Tony Li »

Hi,

Say you need 3 moons.

Inspect the Not Enough Moons node, and set the Conditions field to:

Code: Select all

CurrentMoonsForDialogueSystem() < 3
Then inspect the Not Enough Moons node, and set the Conditions field to:

Code: Select all

CurrentMoonsForDialogueSystem() >= 3
Frank11
Posts: 4
Joined: Thu Sep 01, 2022 6:52 pm

Re: Checking an int during conversation

Post by Frank11 »

Thank you so much for the eloquent solution! It worked perfectly.
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Checking an int during conversation

Post by Tony Li »

Glad to help!
Post Reply