Page 1 of 1

Checking an int during conversation

Posted: Thu Sep 29, 2022 12:49 am
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!

Re: Checking an int during conversation

Posted: Thu Sep 29, 2022 8:20 am
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

Re: Checking an int during conversation

Posted: Fri Sep 30, 2022 6:59 pm
by Frank11
Thank you so much for the eloquent solution! It worked perfectly.

Re: Checking an int during conversation

Posted: Fri Sep 30, 2022 9:59 pm
by Tony Li
Glad to help!