nickelpro / simply-portraits

Creative Commons Zero v1.0 Universal
4 stars 1 forks source link

Suggestion: Don't register preCreateChatMessage until "ready" hook has fired #8

Open cs96and opened 1 year ago

cs96and commented 1 year ago

Hi, I'm the author of the Cautious Gamemaster's Pack module.

Currently Simply Portraits registers its preCreateChatMessage hook as soon as the module is loaded. This means that your hook gets in very early in the call chain of preCreateChatMessage functions.

CGMP's preCreateChatMessage does not get registered until the setup hook has fired. This means that my preCreateChatMessage function is always called after yours. This creates a problem, as CGMP may alter the speaker of a message. Therefore Simply Portraits calculates the speaker's portrait from the old speaker data, i.e. before CGMP has had a chance to alter it.

Therefore, can I request that Simply Portraits does not create its preCreateChatMessage hook until the ready hook has fired? This will move it down the call chain, and let other modules get in first, and allow them to make changes to the message before you calculate the token image?

E.g...

Hooks.once("ready", () => {
    Hooks.on("preCreateChatMessage", () => {
        // Do stuff
    })
});
nickelpro commented 1 year ago

You don't have to ask so politely, I'll set my jerk of a module straight presently. Clearly it needs to learn some manners about sharing hooks with others

cs96and commented 1 year ago

Thanks!

cs96and commented 1 year ago

Any update on this? Thanks.