-
February 15th, 2022, 16:54 #1
Does onInit for global scripts get called on the client?
Title pretty much says it all. I have a global LUA script defined in base.xml and it looks as though its onInit() function is only getting called on the host side, and not on the client, even though I know for a fact that other functions in that script are executing on the client side. Is the logic for when onInit() is called different for clients?
-
February 15th, 2022, 21:35 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,561
Yes, the onInit is fired on the client as well as the host.
One big difference to note between client and host is that any public database nodes will not be available on the client during the onInit process, since the database is streamed in after the tabletop initializes. So, if you are depending on database access, you'll probably need to refactor your client-specific code to wait for the database node to be created.
Regards,
JPG
-
February 15th, 2022, 21:51 #3Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
February 15th, 2022, 22:41 #4
Thanks, that helps. I'm assuming that the Interface.onDesktopInit assignment line can be wrapped in a "not Session.IsHost" check, since the host should be able to just directly call onDesktopInit and do that stuff there? Or is it better for some reason to just do that unconditionally?
-
February 15th, 2022, 23:55 #5
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,561
If it needs to run in both, I usually just call it in the same way that works for both, since that is simpler code wise.
If there is an script initialization call ordering consideration, then you might break it up, but that is rarely needed. (Since there is no predefined order that scripts get called for onInit and onDesktopInit.)
Regards,
JPG
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks