Phyton: Show unit class in info panel

Discussion in 'Civ4Col - Creation & Customization' started by Isabelxxx, May 28, 2012.

  1. Isabelxxx

    Isabelxxx DoaNE Explorer

    Joined:
    Sep 26, 2010
    Messages:
    381
    I'm currently working on a phyton modification of CVMainInterface.py. I want to obtain the unit class description of an unit:

    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(), ))
    
     
  2. Isabelxxx

    Isabelxxx DoaNE Explorer

    Joined:
    Sep 26, 2010
    Messages:
    381
    ... a stupid error. I was getting random a random class from the UnitInfo file instead of the UnitClassInfo file.

    It should be:

    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(), ))
    
     

Share This Page