CyInterface().addImmediateMessage

Roads

Warlord
Joined
Oct 15, 2006
Messages
106
While reading the forums and trying to figure out just basic things like how to print variables to the screen and file I've constantly run across this command:

Code:
CyInterface().addImmediateMessage

The problem is it just doesn't work and not only that but I can't find CyInterface anywhere. As best I can tell it doesn't exist as a file, class or function.

I finally got a message to print to the PythonDbg log with this bit of code:

Code:
import CvUtil

CvUtil.pyPrint("this is my testing script - dlo")

I read somewhere that CyInterface was no longer included with Civ4. Anyone know the story on this?
 
I know it's in Warlords cause I use it all the time! As for your original question as to how to print variables, here is an example:
CyInterface().addImmediateMessage("TURNS REMAINING = %s to %s"%(iNewCount,self.techName),"")

%s = string
%d = digits? (numbers?)

Something like that... if you want more you can download python and look in the manual that comes with it.
 
Thanks primordial stew but no luck with the statement you use. I have Python installed and can do simple stuff like create and print variables with it. I think my trouble is that I don't understand how the SDK interfaces with Python. I'm guessing this CyInterface() is a class in a SDK file and I don't understand how to reference it in a Python prog.

Ugh I'm beginning to think this stuff is just too hard for an old dog to learn but for now it's back to the tuts.
 
As to where CyInterface comes from.. it must be one of these:

from CvPythonExtensions import *
import CvUtil
import PyHelpers

And for completeness I might need to say that my mod uses the 48 civ Revolutions dll. Most mods that have a lot of python also have a custom dll, so I suppose it's possible that they all just preserved that function.

For debugging my code, I just fire up the game and run the code in it. If there is anything wrong: exit game, fix code, fire up game... repeat as necessary :/
 
Well I think I've found the interface. In Civ4lerts you have this:

Code:
from CvPythonExtensions import CyInterface

Looks like you are right on about where CyInterface comes from. Also I used this code and did away with the error when I referenced CyInterface().

Yep, you are right about firing up the game and checking the code but at some point I'm probably going to need to print something to the screen. Maybe I can figure out how Dr Jiggle did it with Civ4lerts but we are talking some heavy duty stuff there.
 
Back
Top Bottom