I’m currently working on a game engine which uses Python as it’s
scripting language. It uses an embedded Python interpreter so that that
the engine can have more control over it. Anyway, I used to know Python
quite well, but it’s been a few years and I’ve forgotten most of it.
Here’s my problem…
The games created with the engine will have different directories for
different scripts. For example, AI scripts will be in a “logic”
directory, scripts which control map triggers will be in
“/maps/mapname/scripts”, and so on.
With Python’s “import” function, I see no way to include a Python script
from another directory. It also looks like each script must have a
unique name. This isn’t very good for what we want to do.
The only other solution I see is interfacing an “include()” function
into Python from the game engine, which loads the new script’s functions
and classes into the interpreter and accesses them when called from the
original script. This seems a bit complicated, and with so many engines
already using Python for scripting, there must be another way to do it.
Any ideas? Should I just use Ruby or Lua instead?
Please log in or register to post a reply.
from DirOne.DirTwo.DirThree import *
Ah… yes. That was actually simpler than I had expected. :p
That’s one of the beauties of Python! :yes: