Exception with GetLocalizedText in Lua
-
- Posts: 29
- Joined: Sat Mar 27, 2021 7:34 am
Exception with GetLocalizedText in Lua
Hi,
I try to get the localized display name of my actor, but I get an exception.
This is the Dialogue Text:
Are you [lua( GetLocalizedText("Actor", "Chief", "Display Name") )]?
And this is the exception:
Dialogue System: Lua code 'return GetLocalizedText("Actor", "Chief", "Display Name")' 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 thought this Lua function is part of the standard, or do I miss a component?
Thanks, Christian
I try to get the localized display name of my actor, but I get an exception.
This is the Dialogue Text:
Are you [lua( GetLocalizedText("Actor", "Chief", "Display Name") )]?
And this is the exception:
Dialogue System: Lua code 'return GetLocalizedText("Actor", "Chief", "Display Name")' 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 thought this Lua function is part of the standard, or do I miss a component?
Thanks, Christian
Re: Exception with GetLocalizedText in Lua
Hi Christian,
It's part of the standard set of Lua functions, and I just verified that it works correctly in DS version 2.2.22. In DemoScene1, I set the Player actor's Display Name and added this text to the text of Private Hart's first line:
[lua( GetLocalizedText("Actor", "Player", "Display Name") )]
Are there any other prior errors or warnings in the Console?
If you temporarily set the Dialogue Manager's Other Settings > Debug Level to Info and reproduce the issue, does this line appear anywhere before the error?
Dialogue System: Unregistering Lua function 'GetLocalizedText'
Can you back up your project and try updating to version 2.2.22?
It's part of the standard set of Lua functions, and I just verified that it works correctly in DS version 2.2.22. In DemoScene1, I set the Player actor's Display Name and added this text to the text of Private Hart's first line:
[lua( GetLocalizedText("Actor", "Player", "Display Name") )]
Are there any other prior errors or warnings in the Console?
If you temporarily set the Dialogue Manager's Other Settings > Debug Level to Info and reproduce the issue, does this line appear anywhere before the error?
Dialogue System: Unregistering Lua function 'GetLocalizedText'
Can you back up your project and try updating to version 2.2.22?
-
- Posts: 29
- Joined: Sat Mar 27, 2021 7:34 am
Re: Exception with GetLocalizedText in Lua
Hi Tony,
in the demo scene, all Lua functions are registered correctly. In my scene, there are several functions missing. All functions up to the debug entry 'Dialogue System: Loaded master database '' ' are registered. They are registered through the DialogueSystemController.
Dialogue System: Registering Lua function GetEntryBool
UnityEngine.Debug:Log (object)
PixelCrushers.DialogueSystem.Lua:RegisterFunction (string,object,System.Reflection.MethodInfo) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:286)
PixelCrushers.DialogueSystem.DialogueSystemController:RegisterLuaFunctions () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueSystemController.cs:1947)
PixelCrushers.DialogueSystem.DialogueSystemController:Awake () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueSystemController.cs:417)
The functions that are missing come after that and are registered differently. They are somehow registered after some UI event, which is missing in my case:
Dialogue System: Registering Lua function GetLocalizedText
UnityEngine.Debug:Log (object)
PixelCrushers.DialogueSystem.Lua:RegisterFunction (string,object,System.Reflection.MethodInfo) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:286)
PixelCrushers.DialogueSystem.DialogueLua:RegisterDialogueSystemFunctions () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/DB/DialogueLua.cs:593)
PixelCrushers.DialogueSystem.DialogueLua:RegisterLuaFunctions () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/DB/DialogueLua.cs:97)
PixelCrushers.DialogueSystem.DialogueLua/<RegisterLuaFunctionsAfterFrame>d__17:MoveNext () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/DB/DialogueLua.cs:105)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
And BTW, I am on 2.2.22
in the demo scene, all Lua functions are registered correctly. In my scene, there are several functions missing. All functions up to the debug entry 'Dialogue System: Loaded master database '' ' are registered. They are registered through the DialogueSystemController.
Dialogue System: Registering Lua function GetEntryBool
UnityEngine.Debug:Log (object)
PixelCrushers.DialogueSystem.Lua:RegisterFunction (string,object,System.Reflection.MethodInfo) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:286)
PixelCrushers.DialogueSystem.DialogueSystemController:RegisterLuaFunctions () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueSystemController.cs:1947)
PixelCrushers.DialogueSystem.DialogueSystemController:Awake () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueSystemController.cs:417)
The functions that are missing come after that and are registered differently. They are somehow registered after some UI event, which is missing in my case:
Dialogue System: Registering Lua function GetLocalizedText
UnityEngine.Debug:Log (object)
PixelCrushers.DialogueSystem.Lua:RegisterFunction (string,object,System.Reflection.MethodInfo) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:286)
PixelCrushers.DialogueSystem.DialogueLua:RegisterDialogueSystemFunctions () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/DB/DialogueLua.cs:593)
PixelCrushers.DialogueSystem.DialogueLua:RegisterLuaFunctions () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/DB/DialogueLua.cs:97)
PixelCrushers.DialogueSystem.DialogueLua/<RegisterLuaFunctionsAfterFrame>d__17:MoveNext () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/DB/DialogueLua.cs:105)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
And BTW, I am on 2.2.22
Re: Exception with GetLocalizedText in Lua
When you're playing in the editor, is the Game view visible?
Several Lua functions, including GetLocalizedText, wait for the end of the first frame to register. The Unity editor has a quirk where it never triggers the "end of frame" if the Game view is not visible.
Several Lua functions, including GetLocalizedText, wait for the end of the first frame to register. The Unity editor has a quirk where it never triggers the "end of frame" if the Game view is not visible.
-
- Posts: 29
- Joined: Sat Mar 27, 2021 7:34 am
Re: Exception with GetLocalizedText in Lua
Yes, the game view is visible. But it is quite a heavy scene to load.
Re: Exception with GetLocalizedText in Lua
Is the conversation configured to start as soon as the scene starts, like maybe in Awake, OnEnable, or Start? And, if so, is [lua(GetLocalizedText(...))] used in the first dialogue entry? I don't know that it would be a problem; I'm just trying to gather data.
Feel free at any point to send a reproduction project to tony (at) pixelcrushers.com if you like.
Feel free at any point to send a reproduction project to tony (at) pixelcrushers.com if you like.
-
- Posts: 29
- Joined: Sat Mar 27, 2021 7:34 am
Re: Exception with GetLocalizedText in Lua
The conversation is started manually (using the UCC integration), and also starting a different conversation first makes no difference. It also occurs in the build, so it is no issue of the editor.
Which component triggers the registration?
Which component triggers the registration?
-
- Posts: 29
- Joined: Sat Mar 27, 2021 7:34 am
Re: Exception with GetLocalizedText in Lua
I think I found the issue. I have a menu / lobby scene which has no Dialogue Manager, but the DialogueLua static class is already initialized in that scene without a corresponding Lua environment. How to fix this?
Re: Exception with GetLocalizedText in Lua
That should be fine. The Lua class (as in Lua.RegisterFunction) is static, too. I'll try to set up a reproduction scenario here today.
-
- Posts: 29
- Joined: Sat Mar 27, 2021 7:34 am
Re: Exception with GetLocalizedText in Lua
I checked that the functions are indeed registered in the lobby scene, and there are no unregistrations after that. Still, it says they are not registered when trying to access them.