#Name of currently running module

1 messages · Page 1 of 1 (latest)

delicate solstice
#

What's the context?

#

I have 4 modules I'm working on that use a single 5th module that has all the scripting in it.

#

I let each of the 4 "register" itself first, but I don't know if that's the type of thing you're looking for.

elder light
#

Yeah, the context really matters. Specifically, the context of the execution stack where the code is called from

fading laurel
#

Sure! This would be from code that runs from a dialog box that imports journals from the current module.

#

Currently, the journal paths are all hardcoded.

elder light
#

How is "the current module" decided? How is the code supposed to actually figure out where and how it's being run? How is the code actually getting executed specifically (macro, call from inside the module's code, something else)?

fading laurel
#

from inside the module's code. e.g. I could theoretically get it from looking at the URL of the .js file that is executing.

elder light
#

In that case, I feel like the easiest option might be to require the module to pass in an argument telling it where to look for things to import (which would also be more flexible in the long run too)

delicate solstice
#

yeah, and you could set a global variable in the module with the module name (e.g., module-name) to that it can use it for accessing the Compendium.

fading laurel
#

Yes, I am doing that now; but since I also have the name of the module in module.json, it seems duplicative to have to set it in .js directly. 🤔

delicate solstice
#

I tried to do the same thing, but was told setting the global variable was actually the easiest way.