Page 1 of 1

Lua check for bool true

Posted: Tue Jul 09, 2024 1:16 pm
by hrohibil
Hello Tony

I have a public bool called radioFound which starts out as false.

Then after it becomes TRUE, I want to use Lua to check in the node tree that if this condition is true then start this node, but it never evaluates to true..

In the node Condition box I use this to check " setHasRadio = true"

Code: Select all

 public bool radioFound = false;
    private void Awake()
    {

        Lua.RegisterFunction(nameof(setHasRadio), this, SymbolExtensions.GetMethodInfo(() => setHasRadio()));

    }

    bool setHasRadio() { return radioFound; }

Re: Lua check for bool true

Posted: Tue Jul 09, 2024 1:56 pm
by Tony Li
Hi,

In the Conditions box, use:

Code: Select all

setHasRadio() == true
or just:

Code: Select all

setHasRadio()
If that doesn't work, are you sure radioFound is true? Since it's a serialized public variable, you can watch its value in the inspector.

Are there any errors or warnings in the Console window?

You can test the variable by entering this at the bottom of the Dialogue Editor's Watches tab and clicking Run:

Code: Select all

print(setHasRadio())

Re: Lua check for bool true

Posted: Tue Jul 09, 2024 2:26 pm
by hrohibil
Thank you Toni it worked.

But where exactly is the " bottom of the Dialogue Editor's Watches"??

Re: Lua check for bool true

Posted: Tue Jul 09, 2024 3:04 pm
by Tony Li
While playing in the Unity editor, go to the Dialogue Editor window's Watches tab. There's a field at the bottom of the window to enter Lua commands.

Re: Lua check for bool true

Posted: Wed Jul 10, 2024 6:11 am
by hrohibil
Thank you Toni!!!

Re: Lua check for bool true

Posted: Wed Jul 10, 2024 8:14 am
by Tony Li
Glad to help!