I broke Lua Functions...

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
NicoMozes
Posts: 32
Joined: Sun Jun 05, 2022 4:18 am

I broke Lua Functions...

Post by NicoMozes »

Hey Toni,
Happy Sunday!

As always, I hope you are doing very well.

Need once again your assistance, as somehow I have broken the Lua Functions.

I have used them non stop and now suddenly I'm getting the following error:

Code: Select all

Dialogue System: Lua code 'SendMessageSystem("Spoke", "Claire")' 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:252)
PixelCrushers.DialogueSystem.Lua:Run (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:131)
PixelCrushers.DialogueSystem.ConversationModel:ExecuteEntry (PixelCrushers.DialogueSystem.DialogueEntry,PixelCrushers.DialogueSystem.CharacterInfo) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Model/ConversationModel.cs:296)
PixelCrushers.DialogueSystem.ConversationModel:GetState (PixelCrushers.DialogueSystem.DialogueEntry,bool,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Model/ConversationModel.cs:266)
PixelCrushers.DialogueSystem.ConversationModel:GetState (PixelCrushers.DialogueSystem.DialogueEntry) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Model/ConversationModel.cs:354)
PixelCrushers.DialogueSystem.ConversationController:OnFinishedSubtitle (object,System.EventArgs) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:318)
PixelCrushers.DialogueSystem.ConversationView:FinishSubtitle () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:441)
PixelCrushers.DialogueSystem.ConversationView:HandleContinueButtonClick () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:413)
PixelCrushers.DialogueSystem.ConversationView:OnConversationContinue (PixelCrushers.DialogueSystem.IDialogueUI) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:392)
UnityEngine.Component:SendMessage (string,object,UnityEngine.SendMessageOptions)
PixelCrushers.DialogueSystem.AbstractDialogueUI:OnContinueConversation () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/UI/Abstract/Dialogue/AbstractDialogueUI.cs:375)
PixelCrushers.DialogueSystem.AbstractDialogueUI:OnContinue () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/UI/Abstract/Dialogue/AbstractDialogueUI.cs:365)
PixelCrushers.DialogueSystem.StandardUIContinueButtonFastForward:OnFastForward () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/UI/Standard/Effects/StandardUIContinueButtonFastForward.cs:86)
UnityEngine.EventSystems.EventSystem:Update () (at ./Library/PackageCache/com.unity.ugui/Runtime/UGUI/EventSystem/EventSystem.cs:530)
When I activate the Debug in the controller it shows that the function is being registered, and the controller is active when I run the dialogue, so not sure how this happened.

Any clue where I should look?

Thanks in advance!
Nico
Attachments
Register OK.png
Register OK.png (122.36 KiB) Viewed 279 times
User avatar
Tony Li
Posts: 23395
Joined: Thu Jul 18, 2013 1:27 pm

Re: I broke Lua Functions...

Post by Tony Li »

Hi,

Is something unregistering it? Look later in the Console logs for a message like:

Dialogue System: Unregistering Lua function SendMessageSystem
NicoMozes
Posts: 32
Joined: Sun Jun 05, 2022 4:18 am

Re: I broke Lua Functions...

Post by NicoMozes »

Hi Tony,

These 3 functions get unregistered:
RandomizeNextEntry
RandomizeNextEntryNoDuplicate
UpdateTracker

Another odd point is that upon opening the project, the first time I run the dialogue works.

Hit stop, and then Play again, and the error appears again.

Close the project and Open it again, and the same thing happens…
NicoMozes
Posts: 32
Joined: Sun Jun 05, 2022 4:18 am

Re: I broke Lua Functions...

Post by NicoMozes »

Hi Tony,

I added some debug lines to the CommonLibraryLua class on Enable, and now I know whats happening.

Few days ago I changed the Editor settings when Entering Play mode Settings. Changed from Reload Domain and Scene to Do not reload domain and scene.

I did not know static values would persist even after stopping the game.

Is it safe to remove s_registered?

Thanks,
Nico
User avatar
Tony Li
Posts: 23395
Joined: Thu Jul 18, 2013 1:27 pm

Re: I broke Lua Functions...

Post by Tony Li »

Hi Nico,

The CommonLibraryLua script should have this method, which resets s_registered when you enter play mode:

Code: Select all

#if UNITY_2019_3_OR_NEWER && UNITY_EDITOR
        [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
        static void InitStaticVariables()
        {
            s_registered = false;
        }
#endif
Is that the case in your copy?

What versions of Unity and the Dialogue System are you using? If you're using Unity 6.1 or 6.2b, maybe there's a bug in the Unity version that's causing Unity to call OnEnable before the SubsystemRegistration method.
NicoMozes
Posts: 32
Joined: Sun Jun 05, 2022 4:18 am

Re: I broke Lua Functions...

Post by NicoMozes »

Hi Tony,

I downloaded the DS version 2.2.55 to a new project and indeed the method mentioned above is there.

I will add this to the script in the other project and it should be solved.

Thanks again for the help!

Cheers,
Nico
User avatar
Tony Li
Posts: 23395
Joined: Thu Jul 18, 2013 1:27 pm

Re: I broke Lua Functions...

Post by Tony Li »

Hi,

If you're using a very old version of the Dialogue System in your current project, consider backing up your project, making sure the backup is good, and then updating to 2.2.55 to get all of the latest bug fixes and improvements. You can also review the Release Notes.
Post Reply