That is what the code I included in my first post in this thread does.
The function you want is
VOID setHasPromotion (PromotionType eIndex, BOOL bNewValue)
(You an find this and other helpful functions
here. It does not include all the new functions that the custom DLLs of various mods add, I am not certain that it includes all of the python functions of base BtS either, and occasionally a function does something other than what you except. Still, I often find it quite helpful, and much more convenient than searching through the various Cy____.cpp source files for the DLL.)
This function belongs only to CyUnit type objects. That is what represents the actual units in the game. In most places these objects are referred to as
pUnit (or
pCaster, pOpponet, ect), but under
def onUnitCreated(self, argsList): in CvEventManager.py the unit which was just created is called
unit.
To call a function you write the name of the object (technically variable that serves as a pointer for the object), a
. and then the name of the function.
VOID means that this function does not return anything, so you cannot define a variable as equaling the result of this function.
BOOL bNewValue is a boolean (true or false) value. True tells the function to give the unit the promotion (if it does not already have it). Falls tells the function to remove the promotion (if it has it already).
PromotionType eIndex is an integer, which refers to the promotion's location in the file CIV4PromotionInfos.xml. The first promotion is 0, the second is 1, etc. If you know the location of the promotion in question (and are sure that you will never rearrange the file), then you could just type that integer. You would not normally want to do that, however,
In order to find the index of a promotion (or religion, or unit, or building, or almost anything else) you generally use
INT getInfoTypeForString (STRING szInfoType)
This is a function of the CyGlobalContext() object. Since this is used so frequently, most files define gc = CyGlobalContext() so you can just type things like gc.getInfoTypeForString( )
INT means that this function returns an integer, specifically the index defining the location of the promotion/unit/whatever in the file where it is found.
STRING szInfoType refers to the string (which is an immutable list of characters, usually letters) whose location you wish to find. You want it to be whatever is found between <Type> & </Type> for the promotion (or whatever). (It could also be things like the unitclass found between <Class> & </Class> or the unitcombat found between <Combat> & </Combat>, but that is not relevant to what you want to do here.)
The starting settler promotion is added by the line
unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STARTING_SETTLER'), True)
The two conditional statements I placed above that are there to narrow down which units get the promotions. Without them, every unit that is ever created would get the promotion for free. The first conditional limits that to only settlers, and the second one makes it apply only when the unit's owner does now control any cities.
(edit: I noticed that it looks like there is a space within the word PROMOTION, but there should not be. That is a fault of the parser on this forum. You should copy the code form my previous post, which was preserved properly thanks to the [code][/code] tags. That also kept it indented correctly, which is important in python. The first conditional should line up with unit = argsList[0] (indented one tab more than the header def onUnitCreated(self, argsList)

, the second be indented once more, and the line actually setting the promotion indented once more within that.)