Registered Lua function throwing exception.
Posted: Wed Oct 06, 2021 2:54 pm
Registered Lua functions are throwing exception when accessed via dialogue during play. Not sure what to do about this error--but it basically cripples my ability to move forward, so any help is much appreciated.
Registered the following function on a scriptable object in the scene:
Registered in OnEnable() with the following:
Successful registration log:
Exception log:
Registered the following function on a scriptable object in the scene:
Code: Select all
public void AddStoryScore(double value)
{
storyScore += value;
OnScoreChange?.Invoke();
}
Code: Select all
Lua.RegisterFunction("AddStoryScore", this, SymbolExtensions.GetMethodInfo(() => AddStoryScore(0)));
Successful registration log:
Code: Select all
Dialogue System: Registering Lua function AddStoryScore
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)
DungeonMasterTycoon.Score:OnEnable () (at Assets/Scripts/DM/Score.cs:76)
Code: Select all
Dialogue System: Lua code 'AddStoryScore(1)' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
UnityEngine.Debug:LogError (object)
PixelCrushers.DialogueSystem.Lua:RunRaw (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:228)
PixelCrushers.DialogueSystem.Lua:Run (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:129)
PixelCrushers.DialogueSystem.ConversationModel:GetState (PixelCrushers.DialogueSystem.DialogueEntry,bool,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Model/ConversationModel.cs:234)
PixelCrushers.DialogueSystem.ConversationModel:GetState (PixelCrushers.DialogueSystem.DialogueEntry) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Model/ConversationModel.cs:304)
PixelCrushers.DialogueSystem.ConversationController:OnSelectedResponse (object,PixelCrushers.DialogueSystem.SelectedResponseEventArgs) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:304)
PixelCrushers.DialogueSystem.ConversationView:SelectResponse (PixelCrushers.DialogueSystem.SelectedResponseEventArgs) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:494)
PixelCrushers.DialogueSystem.ConversationView:OnSelectedResponse (object,PixelCrushers.DialogueSystem.SelectedResponseEventArgs) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:487)
PixelCrushers.DialogueSystem.AbstractDialogueUI:OnClick (object) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/UI/Abstract/Dialogue/AbstractDialogueUI.cs:346)
PixelCrushers.DialogueSystem.StandardDialogueUI:OnClick (object) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/UI/Standard/Dialogue/StandardDialogueUI.cs:260)
PixelCrushers.DialogueSystem.StandardUIResponseButton:OnClick () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/UI/Standard/Dialogue/StandardUIResponseButton.cs:132)
UnityEngine.EventSystems.EventSystem:Update () (at Z:/Program Files/Unity Editors/2020.3.6f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:385)