Page 1 of 2
Loading new scene unregisters Lua functions
Posted: Mon Jun 06, 2022 12:04 pm
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.
Re: Loading new scene unregisters Lua functions
Posted: Mon Jun 06, 2022 1:00 pm
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.
Re: Loading new scene unregisters Lua functions
Posted: Mon Jun 06, 2022 1:23 pm
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.
Re: Loading new scene unregisters Lua functions
Posted: Mon Jun 06, 2022 1:43 pm
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.
Re: Loading new scene unregisters Lua functions
Posted: Mon Jun 06, 2022 2:00 pm
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.
Re: Loading new scene unregisters Lua functions
Posted: Mon Jun 06, 2022 2:06 pm
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?
Re: Loading new scene unregisters Lua functions
Posted: Mon Jun 06, 2022 2:09 pm
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?
Re: Loading new scene unregisters Lua functions
Posted: Mon Jun 06, 2022 2:17 pm
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.
Re: Loading new scene unregisters Lua functions
Posted: Mon Jun 06, 2022 2:26 pm
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.
Re: Loading new scene unregisters Lua functions
Posted: Mon Jun 06, 2022 2:48 pm
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.
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