Loading new scene unregisters Lua functions

Announcements, support questions, and discussion for the Dialogue System.
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Loading new scene unregisters Lua functions

Post by F1foux »

Hi Tony,

I have a dialogue in which the last dialogue entry triggers a scene transition. It transitions well but the dialogue system won't trigger any of my BoltEvents in the new scene. It gives me the error:

Code: Select all

Dialogue System: Lua code 'BoltEvent("Target", "PressButton")' 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)
Do I have to manually change something before transitioning to the next scene? I'm not using the save system so I guess it uses Unitys scene manager, right?

Thx for your help.
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Re: Loading new scene unregisters Lua functions

Post by F1foux »

I've added a Dialogue System Saver, PlayerPrefs Saved game Data Storer, a Json Data Serializer and the Save System Component to the DIalogue Manager now. So now it should automatically use your save system, right?

Unfortunatelly it still gives me the same Lua-Error.
User avatar
Tony Li
Posts: 22148
Joined: Thu Jul 18, 2013 1:27 pm

Re: Loading new scene unregisters Lua functions

Post by Tony Li »

Hi,

Did you add the DialogueSystemBoltLua script to your Dialogue Manager? Or did you add it to a GameObject in the first scene that gets destroyed when you leave the scene? If you added it to a GameObject in the first scene, try adding it to the Dialogue Manager instead.

To change scenes using the save system, use any of these techniques.
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Re: Loading new scene unregisters Lua functions

Post by F1foux »

Hi Tony,
The Dialogue System Bolt Lua component is already added to the dialogue manager. I just played the scene with the Dialogue Manager set to Info and there is nothing about it unregistering the Bolt Functions in the console.

I use the "LoadLevel()" sequencer command to switch scenes.
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Re: Loading new scene unregisters Lua functions

Post by F1foux »

Ok... I played it again and now I see in the console that the DS is unregistering all BoltEvents when the scene transition happens.

I've attached a screenshot from all the scripts on the DIalogue Manager. I don't know if this helps.
Attachments
Scripts on the Dialogue Manager
Scripts on the Dialogue Manager
image_2022-06-06_200619389.png (72.85 KiB) Viewed 719 times
Last edited by F1foux on Mon Jun 06, 2022 2:07 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22148
Joined: Thu Jul 18, 2013 1:27 pm

Re: Loading new scene unregisters Lua functions

Post by Tony Li »

It shouldn't unregister the Lua functions. Unless you turned off the Dialogue Manager's Other Settings > Don't Destroy On Load?
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Re: Loading new scene unregisters Lua functions

Post by F1foux »

When I try to untick the Dont destroy on Load checkbox on the DM it doesn't let me because of the save system. I've attached a screenshot on the previous post. Shouldn't I put the save system on the DM then?
User avatar
Tony Li
Posts: 22148
Joined: Thu Jul 18, 2013 1:27 pm

Re: Loading new scene unregisters Lua functions

Post by Tony Li »

You should not untick Don't Destroy On Load. Please leave it ticked.

Make sure the SaveSystem component is only one one GameObject (e.g., the Dialogue Manager). Same for the InputDeviceManager component.
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Re: Loading new scene unregisters Lua functions

Post by F1foux »

Ok, sry I missread the part about "dont destroy on load".
Both of the components you mentioned are only on the DM.

Would it be possible to manually reregister the Bolt Lua functions per script in the new scene?

Unfortunatelly I can't code and I only use Bolt so I'm really lost right now. I'm sorry to take up so much of your time, but your help is much appreciated.
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Re: Loading new scene unregisters Lua functions

Post by F1foux »

Ok I found the error.

There was another object with the "DIalogue System Bolt Lua" component on it which caused the Functions to be unregistered when the scene transition happened because it only existed in the first scene.

I'm so sorry to have taken up your time Tony.

I don't know if you already mentioned this in the documentation, but just so coding dummies like me won't bother you in the future. Maybe you could mention somwhere that there only should be a "DIalogue System Bolt Lua" component on the DM and nowhere else in the scene. :D

Thank you so much for your time and again, thank you for creating this great asset so even dummies like me can create games!

Cheers
Post Reply