DICE PACKS BUNDLE
  1. #1

    Join Date
    Sep 2020
    Location
    Ballston Lake, NY
    Posts
    600

    Module.activate() Not Working on Client

    I have an extension with a block of code that activates a few modules on the host and client on startup.
    At some point the client side stopped working. I noticed it recently when I added a new module and the players said they didn't see it.
    In testing, I confirmed that the Module.activate works on the host machine but not the client for all modules.
    Permissions are set correctly on the host. On the client, in the Module Activation window, looking at the list of available modules, all the modules show as available and loadable. The player can manually load all the modules, so it's not permissions.

    Here's my block of code:
    Code:
    for _,modules in ipairs(moduleset) do
    	for _,module in ipairs(modules.modules) do
    		local info = Module.getModuleInfo(module.name)
    		if info and not info.loaded then
    			Module.activate(module.name)
    Debug.console(module.name .. " post-activate: loaded", info.loaded, "loading", info.loading, "permission", info.permission)
    		end
    	end
    end
    I added a debug line. On the host machine it emits this:
    Code:
    [2/20/2024 8:02:31 PM] s'SWADE Player Guide post-activate: loaded' | bFALSE | s'loading' | bFALSE | s'permission' | s'allow'
    [2/20/2024 8:02:31 PM] s'Quar Dai - Player post-activate: loaded' | bFALSE | s'loading' | bFALSE | s'permission' | s'allow'
    [2/20/2024 8:02:32 PM] s'SWADE Effects post-activate: loaded' | bFALSE | s'loading' | bFALSE | s'permission' | s'allow'
    [2/20/2024 8:02:32 PM] s'SWADE Adventure Deck post-activate: loaded' | bFALSE | s'loading' | bFALSE | s'permission' | s'allow'
    [2/20/2024 8:02:32 PM] s'Mike's Random Tables post-activate: loaded' | bFALSE | s'loading' | bFALSE | s'permission' | s'allow'
    [2/20/2024 8:02:32 PM] s'Quar Dai Adventure Deck post-activate: loaded' | bFALSE | s'loading' | bFALSE | s'permission' | s'allow'
    On the client machine it emits this:
    Code:
    [2/20/2024 8:03:19 PM] s'SWADE Player Guide post-activate: loaded' | bFALSE | s'loading' | bFALSE | s'permission' | s'disallow'
    [2/20/2024 8:03:19 PM] s'Quar Dai - Player post-activate: loaded' | bFALSE | s'loading' | bFALSE | s'permission' | s'disallow'
    [2/20/2024 8:03:19 PM] s'SWADE Effects post-activate: loaded' | bFALSE | s'loading' | bFALSE | s'permission' | s'disallow'
    [2/20/2024 8:03:19 PM] s'SWADE Adventure Deck post-activate: loaded' | bFALSE | s'loading' | bFALSE | s'permission' | s'disallow'
    [2/20/2024 8:03:19 PM] s'Mike's Random Tables post-activate: loaded' | bFALSE | s'loading' | bFALSE | s'permission' | s'disallow'
    [2/20/2024 8:03:19 PM] s'Quar Dai Adventure Deck post-activate: loaded' | bFALSE | s'loading' | bFALSE | s'permission' | s'disallow'
    Of note is the fact that all these modules are loaded on the host, yet it indicates they're not loaded and enters the if block, after which loaded is still false.
    None of these modules are loaded on the client machine, but they're installed.

    I even added a block for the host to set permissions. That made no difference.
    Code:
    if Session.IsHost then
    	moduleset = aDataModuleSet["client"]
    		for _,modules in ipairs(moduleset) do
    			for _,module in ipairs(modules.modules) do
    				Module.setModulePermissions(module.name, "allow")
    			end
    		end
    	end

    Did something change?
    Thanks in advance.

  2. #2
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    -7 UTC
    Posts
    17,277
    Blog Entries
    9
    MOD: moved to Workshop since this is better addressed as a community developer question.

    Problems? See; How to Report Issues, Bugs & Problems
    On Licensing & Distributing Community Content
    Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets, Balance Disturbed, Dungeon Room Descriptions
    Note, I am not a SmiteWorks employee or representative, I'm just a user like you.

  3. #3
    When are you triggering the load on the player client? onInit, onTabletopInit, onDataLoaded?

    Regards,
    JPG

  4. #4

    Join Date
    Sep 2020
    Location
    Ballston Lake, NY
    Posts
    600
    I'm calling it from OnInit for both host and client.
    Should I use one of the other events for either or both?
    Thanks!

  5. #5

    Join Date
    Sep 2020
    Location
    Ballston Lake, NY
    Posts
    600
    I tried a few things based on your suggestion.
    The onDataLoaded event never fires.
    The onTabletopInit fires after all the modules load, but that had the same results as onInit. If that's a better place to put Module.activate I'll keep it there.
    I put Debug.console on the lines just before and just after Module.activate.
    Module.activate is being called from the host, but it's not activating the modules.
    When I check the module info, it shows permission set to 'disallow'.
    The problem isn't where I'm calling Module.activate, it's that the modules have the wrong permission set on the host.
    I double checked that the module permissions are set correctly.
    They're correct on the host and the client.
    While initializing, the client indicates permission is disallow, but in the Module Activation window, those modules are listed and I can manually load them.
    Somewhere between initializing and the activation window displaying, permissions are set correctly.
    Shouldn't those permissions be set correctly from the outset? They used to be, because this code worked before.

    Thank you for the help!

  6. #6

    Join Date
    Sep 2020
    Location
    Ballston Lake, NY
    Posts
    600
    As a note, I use the Desktop.addDataModuleSet method to add a button to the campaign setup.
    That works fine. The button appears, and when the player clicks it, all the modules load as expected.
    The modules just don't load from Module.activate on init.
    I think this points back to the permissions being set wrong, or not being set from the host before the init events fires, more likely.

  7. #7
    My apologies, you can register an event to be notified when all the data has loaded. Example from WindowSaveManager in CoreRPG:
    Code:
    function onTabletopInit()
    	if OptionsManager.isOption("WSAV", "on") then
    		DB.addEventHandler("onDataLoaded", WindowSaveManager.onDataLoaded);
    	end
    end
    function onDataLoaded()
            ...
    end
    You will definitely need to wait until onTabletopInit call or onDataLoaded event to check.

    Regards,
    JPG

  8. #8

    Join Date
    Sep 2020
    Location
    Ballston Lake, NY
    Posts
    600
    I added the event and moved the code to the onDataLoaded callback.
    That did it! Thank you.
    It's an important note that accessibility of modules is not set until later in the client startup process.
    Thank you Moon Wizard.

  9. #9
    Yeah, I had a similar situation, where saved windows couldn't be restored for campaign data, because it hadn't been streamed in yet from host. Thus, I added a new event to help with that. Glad it helped you too.

    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