Testing some basics - getting a Lua error

Announcements, support questions, and discussion for the Dialogue System.
Jamez0r
Posts: 59
Joined: Fri Nov 20, 2020 8:18 pm

Testing some basics - getting a Lua error

Post by Jamez0r »

Hello, I just purchased the Dialogue System and I'm working my way through the tutorials/documentation. I wanted to test the RandomElement() lua function, with the example from this documentation page: http://www.pixelcrushers.com/dialogue_s ... d_lua.html

I'm getting this error:

Code: Select all

Dialogue System: Lua code 'return RandomElement(Variable["Honorifics"])' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
I triple checked that my syntax and spelling was correct (I copy/pasted the lines from the documentation).

Screenshots of my setup:

Image
Image
Image

Is there a step I might have skipped, or something I could check? I googled/searched this forum and people who had the similar "Tried to invoke a function..." error seemed to be for custom functions that they would have defined, not built-in ones.

Worth noting that I am using Unity version 2020.2.0b8. I also restarted my Unity project once just in case.

Thanks a lot for any help!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Testing some basics - getting a Lua error

Post by Tony Li »

Hi,

Thanks for buying the Dialogue System!

Have you disabled domain reloading in your project by any chance? There was an issue in 2020 that needed to be accommodated when disabling domain reloading. The Dialogue System Extras page has a patch. (direct download link)
Jamez0r
Posts: 59
Joined: Fri Nov 20, 2020 8:18 pm

Re: Testing some basics - getting a Lua error

Post by Jamez0r »

Hi Tony! Thanks a lot for the quick response!

I have not disabled domain reloading on my project.

I made a fresh project to test this out - getting the same error there.

This is what I did on the new project (the extra steps might be irrelevant, but wanted to include them just in case):
1) Created project using the 2D Template with Unity version 2020.2.0b8.
2) In Package Manager, downloaded the Dialogue System v 2.2.13
3) Also downloaded the Timeline package v 1.4.3, since I had done that in my main project
4) In the Welcome window for Dialogue System, I enabled 2D Physics, Timeline, Cinemachine, and TextMeshPro
5) Set up a super basic conversation that used the same Honorifics lua command

Heres the barebones repro project: [snipped]

Going to download the newest beta version 2020.2.0b12 and see if the problem still exists. Will report back in like half an hour 8-)
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Testing some basics - getting a Lua error

Post by Tony Li »

Thanks! (I removed the project link from your post.) I'm downloading it now, and I'll let you know what I find. There have been no end to 2020 alpha and beta bugs, so I suspect that's what's going on. While I download and check out the file you linked, can you try the project in a release version of Unity (i.e., not alpha or beta)?
Jamez0r
Posts: 59
Joined: Fri Nov 20, 2020 8:18 pm

Re: Testing some basics - getting a Lua error

Post by Jamez0r »

Tony Li wrote: Sat Nov 21, 2020 1:37 pm Thanks! (I removed the project link from your post.) I'm downloading it now, and I'll let you know what I find. There have been no end to 2020 alpha and beta bugs, so I suspect that's what's going on. While I download and check out the file you linked, can you try the project in a release version of Unity (i.e., not alpha or beta)?
Ahh geez, sorry for the added frustration :oops: I wouldn't be using this Beta version except for there being a crucial addition for my project added in 2020.2 beta (secondary-texture atlases for sprites).

I made a test project with 2020.1.8f1 and the lua command did indeed work fine.

About to test with the 2020.2.0b12 version and see if anything changed between 0b8 and 0b12.
Jamez0r
Posts: 59
Joined: Fri Nov 20, 2020 8:18 pm

Re: Testing some basics - getting a Lua error

Post by Jamez0r »

Damn, yeah same error on 2020.2.0b12
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Testing some basics - getting a Lua error

Post by Tony Li »

Hmm, I confirmed the error (in 2020.2.b8) in your project. Then I imported the patch, and it works. I updated the patch recently but nothing that should affect this particular issue. Would you please try downloading the latest patch from the Dialogue System Extras page to make sure it resolves the issue in your project?

If it doesn't, then until Unity fixes whatever issue they're having in the beta version, you can drop this script onto the Dialogue Manager to make sure the Lua functions are present:

RegisterBuiltInLuaFunctions.cs

Code: Select all

using System.Reflection;
using UnityEngine;
using PixelCrushers.DialogueSystem;

public class RegisterBuiltInLuaFunctions : MonoBehaviour
{
    void Start()
    {
        var method = typeof(DialogueLua).GetMethod("RegisterLuaFunctions", BindingFlags.Static | BindingFlags.NonPublic);
        method.Invoke(obj: null, new object[] { });
    }
}
Jamez0r
Posts: 59
Joined: Fri Nov 20, 2020 8:18 pm

Re: Testing some basics - getting a Lua error

Post by Jamez0r »

Tony Li wrote: Sat Nov 21, 2020 3:14 pm Hmm, I confirmed the error (in 2020.2.b8) in your project. Then I imported the patch, and it works. I updated the patch recently but nothing that should affect this particular issue. Would you please try downloading the latest patch from the Dialogue System Extras page to make sure it resolves the issue in your project?

If it doesn't, then until Unity fixes whatever issue they're having in the beta version, you can drop this script onto the Dialogue Manager to make sure the Lua functions are present:

RegisterBuiltInLuaFunctions.cs

Code: Select all

using System.Reflection;
using UnityEngine;
using PixelCrushers.DialogueSystem;

public class RegisterBuiltInLuaFunctions : MonoBehaviour
{
    void Start()
    {
        var method = typeof(DialogueLua).GetMethod("RegisterLuaFunctions", BindingFlags.Static | BindingFlags.NonPublic);
        method.Invoke(obj: null, new object[] { });
    }
}
The patch did work! Thanks Tony!!!

Now back to my documentation read-through 8-)
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Testing some basics - getting a Lua error

Post by Tony Li »

Out of curiosity, was it the patch package that fixed it, or did you have to resort to the script in my previous reply? (In my testing, the patch package by itself fixed it.)
Jamez0r
Posts: 59
Joined: Fri Nov 20, 2020 8:18 pm

Re: Testing some basics - getting a Lua error

Post by Jamez0r »

Just the patch - applied it and was good to go!
Post Reply