• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

The Modding Q&A Thread

How do u enable python exceptions?

Find and open your Civilization4.INI by
opening My Documents/My Games/Beyond the Sword/CivilizationIV.ini,
or opening _Civ4Config in your main Beyond the Sword folder (the same that contains Mods)

Inside the file, using Notepad:
- Find "LoggingEnabled" and change it from 0 to 1
- Find "ShowPythonDebugMsgs" and it from 0 to 1

if you can't find one of these, then add it at the end of file i.e. type:
ShowPythonDebugMsgs = 1

It's also useful to enable cheat/debug mode in the same file, as it provides you console and more useful in-game information:
Spoiler :
CheatCode = chipotle


Remember that enabling logs/exceptions slows the game down, but provides you with logs and in-game information about Python errors.
 
I feel like a noob but I cant find _Civ4Config anywhere

Alternatively try:
My Documents/My Games/Beyond the Sword/CivilizationIV.ini
 
Let me clarify that those "extra" parentheses aren't C++ thing - they're not just proper but absolutely obligatory in just about every major language out there, so everyone who touched programming before has this (proper) habit. Interesingly, they've always pissed me off as useless crap and out of 12 or so languages I've used Python is the first one that had the balls to drop them ;) The result is that I now tend to drop those parentheses as well as semicolons while doing work in other stuff and it drives me nuts. Python is really an oddball that defies many established programming conventions.
And how! Some days ago I found myself typing "if (bool1 and bool2){}" in C++ ... while in Python I always get exceptions thrown at me for using && and || as junctors.
 
@embryodead: There is no setPower- should I make setStability? Does pStream read Python information? Because I have no idea how it can work with just changing name of variable (I like to know what I'm doing :P). If I compile successfully how can I check if it's working?

Yes, make setStability - of course you can use changeStability, but it will be more convenient considering RFC uses setStability. I assume you know how to do it, looking at changeStability?

pStream is for reading/writing savegames, i.e. the line makes sure your variable is loaded/saved properly.

Python part is in CyPlayer.cpp/h and CyPlayerInterface1/2. Those files are nothing but DLL->Python interfaces. i.e. in CyPlayer you declare get/setStability, and these functions only call get/setStability from CvPlayer. Whatever is properly added to CyPlayer/CyPlayerInterface should work in Python. To test if it's working, simply start the game, open Python console and try something like this:

pPlayer=gc.getPlayer(0)
print pPlayer.getStability()
pPlayer.setStability(10)
print pPlayer.getStabiltiy()

It should say 0, then 10.

Save the game, reload and type
print gc.getPlayer(0).getStability()

It should say 10 - which means pStream is working.

If it's working, modify get/setStability in StoredData.py so that it uses pPlayer.get/setStability instead of scriptData, and you're done.
 
The classic
Code:
print("hello world")
where exactly is it printed to? Is there a console or something?
 
You have to enable logging in the Civ4Config file first, it's printed into the PythonDbg text file then. You can find it in "My Games\Beyond the Sword\Logs\".
 
Okay, thanks.
 
civ-addicted: Yeah, there is actually a console. How to open it without a standard US keyboard is another issue altogether... :p
 
Thanks! But how do I change StoredData.py if there is no get/set Stability?

Sorry I forgot that in RFCMarathon, set/getStability is in RFCUtils.py and Stability.py
In both files change:
Code:
        def getStability( self, iCiv ):
                return sd.scriptDict['lStability'][iCiv]

        def setStability( self, iCiv, iNewValue ):
                sd.scriptDict['lStability'][iCiv] = iNewValue

to:

Code:
        def getStability( self, iCiv ):
                return gc.getPlayer(iCiv).getStability()

        def setStability( self, iCiv, iNewValue ):
                gc.getPlayer(iCiv).setStability(iNewValue)
 
Im still not having any luck changing the culture of the independent city. Just for the record, I only have to make the change Riseandfall.py right

On a completely different note: do i have to recompile the dll if i use winmerge to import changes
 
The change is definitely right where you've put it. Don't you get a Python exception when loading RFC or at lest at the date the code is supposed to trigger?

And you need to recompile the DLL every time you change the C++ source code, yes.
 
J. Pride, do you know what a Python exception is? Are you sure that you're not getting any either at startup or at run-time?
 
I cannot enable Python exceptions because I dont have the "ShowPythonDebugMsgs" in the Civ4.ini file but even when i add it, i dont get the exceptions ( i had already changed Enabled Logging). I really cant tell what im doing wrong since pasted everything exactly as it was posted here.

BTW: With my latest modification, i get defeat on spawn but before that the game would continue just fine but the change would just not take place. I have a feeling that its not the indentations that are wrong but the command is not being recognized becuase ive been able to make unit spawns just fine.
Its actually funny how hard it is to explain even little changes. Im sorry for wasting ur time :(
 
Create a intentional syntax error by garbling up some line of code. If it doesn't show anywhere, then you've not been able to enable exceptions.

Also note that you need to enable exceptions in the \Documents\Games\BtS\CivilizationIV.ini file - not the .ini file of RFC.
 
You also have to find HidePythonExceptions and set it to 0 - otherwise the exceptions will only be displayed in the logs, not during runtime.
 
Hello,

I want to do a some experiment, and start play with Americans in ~2750 BC (the 10 turn). I changed the tBirth date in Consts.py, ant it works! They were born and I can play with them. Also, I modified the Americans startEra/startingEra from 3 (renaissance) to 0 (ancient) in CvPlayer.cpp and CvCity.cpp, but I have the problem -

Even if I delete the modern American technologies at start from RiseAndFall.py, so they are starting with stone age discoveries, our Americans still are living in the renaissance era. If I will build the first city, then it have 4 population and some buildings at start. Also all of technologies I can get with 1 turn (every technology needs only 1 ressearch point to discover). And, I cannot build the pyramids, stonehenge, the oracle, and the rest of the ancient-classical world wonders.

What I need to do else, to start with the Americans in 3000BC in ancient era?
 
Back
Top Bottom