DICE PACKS BUNDLE
  1. #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?

  2. #2
    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

  3. #3
    Quote Originally Posted by darrenan View Post
    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?
    If you want the DB access for client init you do the following:

    Code:
    function onInit()
    	Interface.onDesktopInit = onDesktopInit;
            ... your stuff... 
    end
    function onDesktopInit()
            ... your client DB stuff...
    end
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  4. #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?

  5. #5
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in