Global Script Module Subroutines

What’s the correct syntax for calling a module within another module?

For instance, under app.* I have two modules: level and levelMod. How does a subroutine in levelMod call a subroutine in level or within its own module?

You get to the function you want by loading the package that it’s stored in. In your example, modules are stored in the app package. Say you want to define test under levelMod that will run the reset function in the level package

In app.levelMod use the following code:

def test(): #import automatic in action scripts #needs to be done manually in modules. import app app.level.reset()

def test(): from app.level import * reset()

Running a different function in the same package can be done the same way.

There are only 2 namespaces in Python - the global namespace and the local one. If the function is defined in either namespace you can call it directly. Otherwise, import the package if you need and “drill down” to the function. Your package structure is just like the built in FactoryPMI Jython packages and functions. The thing that sometimes throws off beginners is that you don’t have to import app and fpmi in action scripts because FactoryPMI does it for you, but you do have to import them from other modules and you have to import all other modules.

Thanks! The modules are working fine now.