How to use CvInfoBase?

Baldyr

"Hit It"
Joined
Dec 5, 2009
Messages
5,530
Location
Sweden
I'm looking at the API and can't figure out how to use the functions under CvInfoBase. The one I need to use is getDomainType() and it returns a integer value. But what do I feed it - and how? :crazyeye: I'm guessing it should be an instance of a class (or something), but I have only the unit type (int).

I can't use the function in the CyPlayer class because I'm trying to sort of out whether or not a unit is land or sea going - prior to creating it. (In order to check whether or not the target plot is valid.)

Does anyone know? :confused:
 
I think you mean something different than CvInfoBase. CvUnitinfo has getDomainType(), what you can do is to use this in python.

GC.getUnitInfo(unitType).getDomainType()
 
Yeah, that makes sense! :king:

Because you would start with CyGlobalContext in any case. I'm probably just tired... :rolleyes:

Thanks a bunch! :goodjob:
 
BTW, CvInfoBase is the parent class of all the CvFooInfo classes so its functions are avaiiable to its children: getType(), getKey(), isGraphicalOnly(), etc.
 
I've been wondering about getKey()... What is a "key"? I also believe there is something like getNameKey() as opposed to simply getName().
 
I believe those keys have to do with translation, but I'm not positive. A key is usually the name given to a value that is used to uniquely identify an item a la an ID. An odd name choice since keys in real life unlock things, but I guess it's that a key "unlocks" access to an item by giving you a way to find it. :) I guess it's the key in "the key to victory"--the one thing that makes another thing accessible/possible.
 
Well, that didn't tell me much of anything, but thanks for the try. :p

I'm using "keys" in my own project also, for looking up city names that may or may not exist once a trigger is activated. Since a trigger is composed of conditions and actions the search values are dubbed "keys", as they are used by both (some) conditions and actions. The Key object will store an alternate set of values (coordinates, city owner, city name) that are used in some instances when the corresponding fields are missing (None) in the other objects. If that makes any sense. :crazyeye:
 
I've been wondering about getKey()... What is a "key"? I also believe there is something like getNameKey() as opposed to simply getName().

Unless I am mistaken, pUnit.getText() returns for example "Swordsman" while pUnit.getKey() returns "TXT_KEY_UNIT_SWORDSMAN".
 
Unless I am mistaken, pUnit.getText() returns for example "Swordsman" while pUnit.getKey() returns "TXT_KEY_UNIT_SWORDSMAN".
Ah, that would explain it. :goodjob:

What about CyCity.getName(), CyCity.getNameForm(int) and CyCity.getNameKey()? :confused:

If it was CyPlayer.getNameKey() or CyPlayer.getNameForm(int) then that would make some sense, but CyCity? :eek:
 
Same as above, getName() = Washington getNameKey = TXT_KEY_CITY_WASHINGTON./QUOTE]
So I could define some XML or what ever to that key string then? Ok, got it.

If I change the name of a city to "Test" the Key will change to "TXT_KEY_CITY_TEST" then? Or do I have to do something else in order to assign a key to a city? Because otherwise it wouldn't have any key at all?

So the key for the city "Washington" could really be set to "TXT_KEY_CITY_CAPITOL" for a more generic approach?
 
er...completly wrong approach :D.

TXT_KEY_CITY_WASHINGTON is defined in the XMLs to have the value "Washington".
Changing the name will probably just lead to -1 be returned when asking for the key, but i'm not sure :dunno:. I guess, if you asign a name which is also somewhere defined in the XML it will not be connected.
 
Top Bottom