I'm currently working on a phyton modification of CVMainInterface.py. I want to obtain the unit class description of an unit:
So far this checks if the unit has a profession, if it hasn't one the unit class should be given instead. This allows us to differentiate between units which have non-generic names, different unit Classes but no professions (ships for ex.). I'm actually using it to show the Unit class in the info panel when selecting an unit.
The problem is that it's not returning me the correct unit class...
If I select a frigate the unit class obtained is not frigate but other, caravel for ex.
Does someone know where is the error?
EDIT: Nevermind, I already found the error. See post 2.
Code:
if (pHeadSelectedUnit.getProfession() == -1):
szBuffer = localText.getText("INTERFACE_PANE_UNIT_NAME", [COLOR="Red"](gc.getUnitInfo(pHeadSelectedUnit.getUnitClassType()).getDescription(), ))[/COLOR]
else:
szBuffer = localText.getText("INTERFACE_PANE_UNIT_NAME", (gc.getProfessionInfo(pHeadSelectedUnit.getProfession()).getDescription(), ))
So far this checks if the unit has a profession, if it hasn't one the unit class should be given instead. This allows us to differentiate between units which have non-generic names, different unit Classes but no professions (ships for ex.). I'm actually using it to show the Unit class in the info panel when selecting an unit.
The problem is that it's not returning me the correct unit class...
If I select a frigate the unit class obtained is not frigate but other, caravel for ex.
Does someone know where is the error?
EDIT: Nevermind, I already found the error. See post 2.
Code:
if (pHeadSelectedUnit.getProfession() == -1):
szBuffer = localText.getText("INTERFACE_PANE_UNIT_NAME", [COLOR="Red"](gc.getUnitClassInfo(pHeadSelectedUnit.getUnitClassType()).getDescription(), ))[/COLOR]
else:
szBuffer = localText.getText("INTERFACE_PANE_UNIT_NAME", (gc.getProfessionInfo(pHeadSelectedUnit.getProfession()).getDescription(), ))