I'm creating a very small Python mod, in fact it's just a single function that opens a remote URL (since this cannot be done from within the SDK's C++ configuration itself). This function is to be called from within the CvGameCore.dll (CvGame.cpp), passing a simple string variable to it.
You with me so far? Good. Now here's where I'm running into a snag: I don't know how to call that function from within the CvGame.cpp file!
As I understand it, here's how the game currently calls the non-mod Python functions:
In CvDefines.h, the following references are declared:
// python module names
#define PYDebugToolModule "CvDebugInterface"
#define PYScreensModule "CvScreensInterface"
#define PYCivModule "CvAppInterface"
#define PYWorldBuilderModule "CvWBInterface"
#define PYPopupModule "CvPopupInterface"
#define PYDiplomacyModule "CvDiplomacyInterface"
#define PYUnitControlModule "CvUnitControlInterface"
#define PYTextMgrModule "CvTextMgrInterface"
#define PYPerfTestModule "CvPerfTest"
#define PYDebugScriptsModule "DebugScripts"
#define PYPitBossModule "PbMain"
#define PYTranslatorModule "CvTranslator"
#define PYGameModule "CvGameInterface"
#define PYEventModule "CvEventInterface"
These are the only header declarations for the Python files that I could find in the SDK, and it only references the interface .py files that are in the following directory: <Civ4 game dir>\Assets\Python\EntryPoints
But, obviously, I wouldn't want to stick my mod in there. It would probably work, but it'd be very sloppy and not the way mods are intended to be installed. So my question is, where would I declare a .py file in the Mods directory? For example, let's say I have function "TestMe()" in the file, "<Civ4 game dir>\Mods\TestMod\MyModFile.py". Where would I declare that in the SDK? We'll return to this example in a moment.
Now let's see how Python functions are already called from within the C++ src. In CvGame.cpp, we have this at line 6155:
"gDLL->getPythonIFace()->callFunction(PYGameModule, "doHolyCity", NULL, &lResult);"
If you scroll back up to CvDefines.h, you'll see that "PYGameModle" refers to "CvGameInterface.py" in the Assets\Python\EntryPoints directory, and "doHolyCity" is the function being called.
So now let's go back to my example. If you remember, we had function "TestMe()" in the file, "<Civ4 game dir>\Mods\TestMod\MyModFile.py". So knowing what we've learned about the syntax, let's call the function from CvGame.cpp as follows:
"gDLL->getPythonIFace()->callFunction(PyTestModule, "TestMe", NULL, &lResult);"
In this example, you can see we're calling function TestMe() from within the Python file specified by PyTestModule.
Still with me so far? Yes? Good. No? Too bad. Anyway, we now run into my not-so-perverbial brick wall. How/where would I define "PyTestModule" so that it would refer to "<Civ4 game dir>\Mods\TestMod\MyModFile.py"? If I just add it to CvDefines.h, then it would presumably look for that file in the EntryPoints directory with the interfaces, not the Mods directory. Now do you understand my problem?
I know this is a long and complicated post, and I'm sure the solution is insultingly simple. But please, for the love of god, somebody respond to this post and at least point me in the right direction! I've searched the forum, read through the Python tutorials, but haven't found anything that answers this question!
Hell, even if you don't know, at least post THAT as a reply just so I know it's not just me! Please! I know I'm not crazy! Well ok, I am crazy, but still! There just HAS to be a way to do this.....
Thanks,
--Kristopher
You with me so far? Good. Now here's where I'm running into a snag: I don't know how to call that function from within the CvGame.cpp file!
As I understand it, here's how the game currently calls the non-mod Python functions:
In CvDefines.h, the following references are declared:
// python module names
#define PYDebugToolModule "CvDebugInterface"
#define PYScreensModule "CvScreensInterface"
#define PYCivModule "CvAppInterface"
#define PYWorldBuilderModule "CvWBInterface"
#define PYPopupModule "CvPopupInterface"
#define PYDiplomacyModule "CvDiplomacyInterface"
#define PYUnitControlModule "CvUnitControlInterface"
#define PYTextMgrModule "CvTextMgrInterface"
#define PYPerfTestModule "CvPerfTest"
#define PYDebugScriptsModule "DebugScripts"
#define PYPitBossModule "PbMain"
#define PYTranslatorModule "CvTranslator"
#define PYGameModule "CvGameInterface"
#define PYEventModule "CvEventInterface"
These are the only header declarations for the Python files that I could find in the SDK, and it only references the interface .py files that are in the following directory: <Civ4 game dir>\Assets\Python\EntryPoints
But, obviously, I wouldn't want to stick my mod in there. It would probably work, but it'd be very sloppy and not the way mods are intended to be installed. So my question is, where would I declare a .py file in the Mods directory? For example, let's say I have function "TestMe()" in the file, "<Civ4 game dir>\Mods\TestMod\MyModFile.py". Where would I declare that in the SDK? We'll return to this example in a moment.
Now let's see how Python functions are already called from within the C++ src. In CvGame.cpp, we have this at line 6155:
"gDLL->getPythonIFace()->callFunction(PYGameModule, "doHolyCity", NULL, &lResult);"
If you scroll back up to CvDefines.h, you'll see that "PYGameModle" refers to "CvGameInterface.py" in the Assets\Python\EntryPoints directory, and "doHolyCity" is the function being called.
So now let's go back to my example. If you remember, we had function "TestMe()" in the file, "<Civ4 game dir>\Mods\TestMod\MyModFile.py". So knowing what we've learned about the syntax, let's call the function from CvGame.cpp as follows:
"gDLL->getPythonIFace()->callFunction(PyTestModule, "TestMe", NULL, &lResult);"
In this example, you can see we're calling function TestMe() from within the Python file specified by PyTestModule.
Still with me so far? Yes? Good. No? Too bad. Anyway, we now run into my not-so-perverbial brick wall. How/where would I define "PyTestModule" so that it would refer to "<Civ4 game dir>\Mods\TestMod\MyModFile.py"? If I just add it to CvDefines.h, then it would presumably look for that file in the EntryPoints directory with the interfaces, not the Mods directory. Now do you understand my problem?
I know this is a long and complicated post, and I'm sure the solution is insultingly simple. But please, for the love of god, somebody respond to this post and at least point me in the right direction! I've searched the forum, read through the Python tutorials, but haven't found anything that answers this question!
Hell, even if you don't know, at least post THAT as a reply just so I know it's not just me! Please! I know I'm not crazy! Well ok, I am crazy, but still! There just HAS to be a way to do this.....

Thanks,
--Kristopher