How does the game engine handle imports?

In scripts, how does the game engine handle importing 3rd party modules? I couldn’t get it to import from the source folder of the saved script. Does it instead have to be loaded to the text editor? Or can you not use modules that are not blender builtins?

for example, if I had a module that defined addNumber(),
and then I wanted to import it into a script running in the game engine.

Generally, if your module is in the same directory as the .blend file, you should be able to import your module as you would any other: “import mymodule” or “from mymodule import addNumber”.

If you want to access modules in some arbitrary directory, you can still do it like this:

import sys

new_path = "/path/to/relevant/directory"

And then you can import modules from that directory in the usual way.