fantasycalendar / FoundryVTT-Sequencer

This module implements a basic pipeline that can be used for managing the flow of a set of functions, effects, sounds, and macros.
Other
47 stars 25 forks source link

[BUG] - Preload macro does not work on version 2.414 #149

Closed Melthemia closed 1 year ago

Melthemia commented 1 year ago

Describe the bug Upon using a macro intended to preload assets, an error occurs and nothing happens. The macro works as intended and the error does not occur on version 2.412 of Sequencer.

To Reproduce Use the following macro, can replace JB2A asset references if need be:

Hooks.on("preloadfiles", async () => {

    let allFiles = [];

    // Everything in this list will be preloaded
    const ookData = {
        _template: { // Grid size, start point, end point
            "default": [100, 0, 0],
            "ranged": [100, 100, 100]
        },
        preload: [
            //
            // Weapon Animations
            //
            "jb2a.melee_generic.bludgeoning.two_handed",
            "jb2a.throwable.throw.grenade",
            "jb2a.throwable.launch.missile",
            "jb2a.bullet",
            "jb2a.flurry_of_blows.physical.orange",
            "jb2a.flurry_of_blows.physical.pinkpurple",
            //
            // Grenade Explosions
            //
            "jb2a.explosion.01.orange",
            "jb2a.explosion.green.3",
            "jb2a.explosion.02.blue",
            "jb2a.explosion.blueyellow.0",
            "jb2a.fireball.explosion.orange",
            "jb2a.explosion.green.3",
            "jb2a.explosion.blue.3",
            "jb2a.explosion.orange.3",
            "jb2a.fog_cloud.2.white",
            //
            // Misc
            //
            "jb2a.ui.miss.red", // Miss Animation
            "jb2a.melee_generic.bludgeoning.two_handed", // Hit Animation   
        ]
    };

    console.log("ookData", ookData);

    // Register the database of entries to preload
    Sequencer.Database.registerEntries("ook", ookData);

    // Now ready for execution of the preload
    Sequencer.Database.getAllFileEntries("ook").forEach((filePath) => allFiles.push(filePath));
    //console.log("allFiles: ", allFiles);
    await Sequencer.Preloader.preloadForClients(allFiles, true);
});
// AFTER all clients are connected, run a second macro (or enter directly in the console:   Hooks.call("preloadfiles");

Followed by this macro:

Hooks.call("preloadfiles");

Expected behavior Assets would be pre-loaded upon execution of the second macro, evident by a loading bar appearing.

Screenshots image

Setup:

Haxxer commented 1 year ago

I am curious why are you registering the entries?

Melthemia commented 1 year ago

I am curious why are you registering the entries?

It's my first time reporting an issue like this, so I was unsure whether to include them or not. Since it doesn't provide the specific error I'm reporting without entries to actually cache, I kept them in. Although in hindsight I simply could have provided a sample test entry instead of the ones I practically use on my own. Regardless, the error is thrown regardless of what entries are contained as long as something is contained there, even if it can't find what the entry is referring to. (I also accidentally closed the issue, my bad. Sorry about that.)

Haxxer commented 1 year ago

Could you just try to do:

Hooks.on("preloadfiles", async () => {

    let allFiles = [];

    // Everything in this list will be preloaded
    const ookData = {
        _template: { // Grid size, start point, end point
            "default": [100, 0, 0],
            "ranged": [100, 100, 100]
        },
        preload: [
            //
            // Weapon Animations
            //
            "jb2a.melee_generic.bludgeoning.two_handed",
            "jb2a.throwable.throw.grenade",
            "jb2a.throwable.launch.missile",
            "jb2a.bullet",
            "jb2a.flurry_of_blows.physical.orange",
            "jb2a.flurry_of_blows.physical.pinkpurple",
            //
            // Grenade Explosions
            //
            "jb2a.explosion.01.orange",
            "jb2a.explosion.green.3",
            "jb2a.explosion.02.blue",
            "jb2a.explosion.blueyellow.0",
            "jb2a.fireball.explosion.orange",
            "jb2a.explosion.green.3",
            "jb2a.explosion.blue.3",
            "jb2a.explosion.orange.3",
            "jb2a.fog_cloud.2.white",
            //
            // Misc
            //
            "jb2a.ui.miss.red", // Miss Animation
            "jb2a.melee_generic.bludgeoning.two_handed", // Hit Animation   
        ]
    };

    await Sequencer.Preloader.preloadForClients(ook.preload, true);
});
// AFTER all clients are connected, run a second macro (or enter directly in the console:   Hooks.call("preloadfiles");
Haxxer commented 1 year ago

You can't add entries the database without giving it files to register, it would be like writing a recipe without providing the ingredients list, it just doesn't make sense

The fact that it worked before was a bug, and the error you now get seems to be more in line what is expected, though probably should have better error handling

Melthemia commented 1 year ago

Unfortunately the macro suggestion didn't appear to work, upon execution of the second macro following the suggested one it throws this error: image I also tried the suggested macro with a few direct references to files as opposed to referring to the database entries generated by JB2A, and there seemed to be no difference. Additionally, I feel it's important to note that I am not the author of the original macro, so I'm not fully familiar with how it functions.

Haxxer commented 1 year ago

Ah apologies, change the ook.preload to ookData.preload, I sent my macro on mobile.

Haxxer commented 1 year ago

In the future, however, do please post in the Foundry discord channels for help :)

Melthemia commented 1 year ago

Ah apologies, change the ook.preload to ookData.preload, I sent my macro on mobile.

This solved it! Thank you very much!

In the future, however, do please post in the Foundry discord channels for help :)

Will do, I posted here since I figured it was a bug. I'll post on Discord in the future if something similar occurs again.