How would I add a world script to my hosted campaigns?

I’m seeking to add some modifiers so that when characters are created/imported, some of their special traits are automatically set (so I don’t have to do it by hand to every one). But I can’t figure out how I would do that with a hosted campaign on Forge.

Any ideas?



Great question! You could certainly try to export the world, edit the json and include the script file, then re-import your world, but the easiest is to use the World Scripter module, I’ve heard only good things about it:

I hope this helps!

Alas, I gave World Scripter a try, but the changes I’m trying to implement, automatically changing the critical threshold on characters in DnD5e system on character creation or compendium import, don’t seem to be taking. I’m still on version 9, since I’m still testing replacement mods to convert my campaigns to 10, so maybe that’s the problem? Alternately, maybe I’m missing a call or statement with the code.

The world code is as follows:

Hooks.on("preCreateActor", actor =>
    "flags.dnd5e.weaponCriticalThreshold": 17,
    "flags.dnd5e.spellCriticalThreshold": 17,

Confirmed that the above works on a local v10 install with World Scripter, but not on a hosted v9 on Forge with World Scripter. Oh well. Looks like I need to speed up my mod testing.

Ah, I see. I think the issue might be that updateSource doesn’t exist in v9? I think it’s a v10 only API and on v9 it was just “update”. You should instead use this I think:

Hooks.on("preCreateActor", actor => {
  actor.setFlag("dnd5e", "weaponCriticalThreshold", 17);
  actor.setFlag("dnd5e", "spellCriticalThreshold", 17);

I hope that helps.

Thanks for the try, but that doesn’t appear to work either. After setting it, I tried both simply refreshing the page, and logging out, shutting the server down, starting it back up and re-joining.

No-go whether importing from compendium or creating a new actor.

While it would have been nice, I have an active Macro work around to update all actors currently loaded into the campaign. So, I’ll just trundle along with that until I’ve got all my new mods tested and can jump to v10.

Thanks again!

PS: And I tried it in debug mode, and got no errors.