How to make Civ4 find a python package?

Jean Elcard

The Flavournator
Joined
Feb 26, 2006
Messages
1,008
Location
Leipzig, Germany
Ok, here is my rather technical python problem formulated in a neutral way:

Situation: I've written a mapscript consisting of the mymapscript.py file itself and a helperfile.py with some extra functionality.

Objective: I would like to put the helperfile.py in its own subdirectory called mysub in the PublicMaps directory to keep the code well structured and to prevent it from showing up ingame as a seemingly valid mapscript, which it of course isn't.

Failed Attempt: I put the helperfile.py together with a __init__.py file in the mysub directory and stated the following code in mymapscript.py in the PublicMaps folder:

Code:
from mysub.helperfile import Stuff

I thought this should work (as it usually does with python outside of civ4), but it doesn't. Any ideas why?
 
you can put the helpfile into Assets\Python. From there it should work with a additional subfolder as well.

I would advice aganst this however - just put all into one file. A separated map script will cause trouble - most notable in Multiplayer.
 
You are right, it's probably better to put everything in one file to keep it easy for the user. The only thing that's bothering me is the redundancy introduced by doing so, because I'm using this helper file in multiple mapscripts. A sub folder in Public Maps for it would still be perfect, but there seems to be no way to tell civ to search there for it.
 
Back
Top Bottom