Unit Naming

VD is a mod that contains ethnic unit and building graphics. BAT is essentially VD + BUG + a few other graphic mods, but this guy is running just BUG with VD it seems.

Keep in mind that the latest version of BUG creates INI files on the fly, and UN is on by default.
 
I cannot load these saves after I load up the mod. My PC isn't big enough(?).
 
I get this error in PythonErr.txt related to unit naming:
Code:
Traceback (most recent call last):

  File "CvEventInterface", line 30, in onEvent

  File "BugEventManager", line 250, in handleEvent

  File "BugEventManager", line 263, in _handleDefaultEvent

  File "UnitNameEventManager", line 250, in onUnitBuilt

  File "UnitNameEventManager", line 401, in getUnitNameConvFromIniFile

  File "BugCore", line 145, in get

AttributeError: 'NoneType' object has no attribute 'isColor'
ERR: Python function onEvent failed, module CvEventInterface

And in PythonDbg.txt:
Code:
12:52:11 ERROR: BugCore - option UnitNaming__Combat_AGE_OF_SAIL not found

I have added the new combat types to the BugUnitNamingOptionsTab.py:
Code:
def create(self, screen):
		tab = self.createTab(screen)
		panel = self.createMainPanel(screen)
		column = self.addOneColumnLayout(screen, panel)
	
		screen.attachHSeparator(column, column + "Sep1")
		left, right = self.addTwoColumnLayout(screen, column, "Options")
		
		self.addCheckbox(screen, left, "UnitNaming__Enabled")
		self.addCheckbox(screen, right, "UnitNaming__UseAdvanced")

		columnL, columnR = self.addTwoColumnLayout(screen, column, "UnitNaming")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Default")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_AGE_OF_SAIL")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_AGE_OF_STEAM")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_AIR")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_ANTIAIR")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_ARCHER")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_ARMOR")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_DREADNOUGHT_AGE")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_GUN")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_HELICOPTER")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_JET_AIR")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_MELEE")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_MODERN_NAVAL")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_MOUNTED")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_NAVAL")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_None")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_NUCLEAR_AGE")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_PRE_DREADNOUGHT_AGE")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_RECON")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_SIEGE")
		self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_TRENCH")

Where else do I need to add these new types? I've looked at the Unit Naming.ini file, but not tried to edit it. If that is indeed where I need to edit, isn't it a little silly to have to do edits outside of the mod directory? It certainly makes it a little more difficult to make a simple zipfile mod... :)
 
Where else do I need to add these new types? I've looked at the Unit Naming.ini file, but not tried to edit it.
Yes. You need to add AGE_OF_SAIL against each unit for the 'advanced' feature to work.
 
ERROR: BugCore - option UnitNaming__Combat_AGE_OF_SAIL not found

It looks like AGE_OF_SAIL is a new CombatType like MELEE and GUNPOWDER. This is not part of the Advanced Unit Naming feature, but it is somewhat related.

BUG has two methods of "placeholder" settings: those that use Python-supplied parameters to determine the actual setting to access. The first method--the one you're using--is used when you want to place those settings onto the options screen. The other method--used by the Advanced Unit Naming feature--doesn't allow for that.

The trick is that options screen requires an actual <option> or <list> defined in the configuration XML for each option on the screen. You then use the <accessor> tag to provide parameterized access to all your options:

Code:
<option id="CombatAGE_OF_SAIL" key="CombatAGE_OF_SAIL" 
        type="string" default="DEFAULT"/>
<accessor get="getByCombatType" set="setByCombatType" 
          args="combatType" id="Combat_%s"/>

To define an option using the second method, you just need a single <option> or <list>:

Code:
<option id="ByEraAndClass" key="%s_%s" args="era, class" 
        type="string" default="DEFAULT"/>

Why the difference? The options screen has translatable labels and hover text which are attached to Python Option objects, and I don't anticipate rewriting the screen to handle the second method of parameterized options. I'll take a look and see how much effort it will be, though.

That being said, what other options (no pun intended) do we have here? You want to be able to define options without modifying the configuration XML file from BUG, right? One thing I can probably add fairly easily would be the ability to tack on options to an existing INI file defined in another XML file. This would let you define the <option> for your new CombatTypes in your XML file, but have them attached to UnitNaming's INI file.

You still need to modify BUG UnitNamingOptionTab as you're doing now, but you don't seem to take issue with that. I assume that's kosher, yes? If so, I'll look into that when I get home tonight.
 
Thanks for that explanation. I'm sure I don't understand all of it! :D All I wanted to know was where to do some extra edits. I found out that it was in Unit Naming.xml (your hint), and the section in that file now looks like this:

Code:
	<option id="Combat_None" key="CombatNone" 
			type="string" default="DEFAULT"/>
	<option id="Combat_AGE_OF_SAIL" key="CombatAGE_OF_SAIL" 
			type="string" default="DEFAULT"/>
	<option id="Combat_AGE_OF_STEAM" key="CombatAGE_OF_STEAM" 
			type="string" default="DEFAULT"/>
	<option id="Combat_AIR" key="CombatAIR" 
			type="string" default="DEFAULT"/>
	<option id="Combat_ANTIAIR" key="CombatANTIAIR" 
			type="string" default="DEFAULT"/>
	<option id="Combat_ARCHER" key="CombatARCHER" 
			type="string" default="DEFAULT"/>
	<option id="Combat_ARMOR" key="CombatARMOR" 
			type="string" default="DEFAULT"/>
	<option id="Combat_DREADNOUGHT_AGE" key="CombatDREADNOUGHT_AGE" 
			type="string" default="DEFAULT"/>
	<option id="Combat_GUN" key="CombatGUN" 
			type="string" default="DEFAULT"/>
	<option id="Combat_HELICOPTER" key="CombatHELICOPTER" 
			type="string" default="DEFAULT"/>
	<option id="Combat_JET_AIR" key="CombatJET_AIR" 
			type="string" default="DEFAULT"/>
	<option id="Combat_MELEE" key="CombatMELEE" 
			type="string" default="DEFAULT"/>
	<option id="Combat_MODERN_NAVAL" key="CombatMODERN_NAVAL" 
			type="string" default="DEFAULT"/>
	<option id="Combat_MOUNTED" key="CombatMOUNTED" 
			type="string" default="DEFAULT"/>
	<option id="Combat_NAVAL" key="CombatNAVAL" 
			type="string" default="DEFAULT"/>
	<option id="Combat_NUCLEAR_AGE" key="CombatNUCLEAR_AGE" 
			type="string" default="DEFAULT"/>
	<option id="Combat_PRE_DREADNOUGHT_AGE" key="CombatPRE_DREADNOUGHT_AGE" 
			type="string" default="DEFAULT"/>
	<option id="Combat_RECON" key="CombatRECON" 
			type="string" default="DEFAULT"/>
	<option id="Combat_SIEGE" key="CombatSIEGE" 
			type="string" default="DEFAULT"/>
	<option id="Combat_TRENCH" key="CombatTRENCH" 
			type="string" default="DEFAULT"/>
	<accessor get="getByCombatType" set="setByCombatType" 
			  args="combatType" id="Combat_%s"/>

Problem solved! :) So for my sake you don't need to spend any time on this.

Cheers!
 
I am still somewhat confused on this module especially how the tt attribute works. So perhaps if I explain what I would like to do and perhaps someone could give me an example.

I am not sure if I want the subdivision at the unit or combat type level, but what I would like to see is 1st Div 1st Melee Bgd or 1st Div 1st Axeman Bgd. Each Axeman/Melee increments to a max of like 20. Then it starts over with 2nd Division. There should be a max there of some number like 4.

Is this possible?
 
sure - I think I can help. How about you rattle off a couple of units with suitable names and I'll see what I can do for getting you a code that works

For Example (fill in what you would like each name below to be - assume that your groups loop at 4 so we don't have to get too carried away):

axe #1 -> 'name'
axe #2 -> 'name'
axe #3 -> 'name'
axe #4 -> 'name'
axe #5 -> 'name'
axe #6 -> 'name'
sword #1 -> 'name'
archer #1 -> 'name'
 
Thanks. Here is what I am looking for...


axe #1 -> '1st Div 1st Axe Bgd'
axe #2 -> '1st Div 2nd Axe Bgd'
axe #3 -> '1st Div 3rd Axe Bgd'
axe #4 -> '1st Div 4th Axe Bgd'
axe #5 -> '1st Div 5th Axe Bgd'
... the axe bgd for 1st Div would go to let's say 10, then ...

axe #6 -> '2nd Div 1st Axe Bgd'
... and so on for 2nd Div, repeat for 3rd and 4th Div ...

sword #1 -> '1st Div 1st Swords Bgd'
... same as the axes ...

archer #1 -> '1st Div 1st Archery Rgmt'
... same as the axes ...

Thanks.
 
Lets break this down into parts. But before we do that ... did you know that you can test your codes in the game? Ctrl-Alt-N will bring up a dialog box that will let you test your naming codes on the unit #1. Now, the required name for the first axe ... "1st Div 1st Axe Bgd" and here is the way to construct the code ...

Step 1 - the easy part ...
The 'Div' and 'Bgd' are easy - just put them in as words.

Naming code = "? Div ? ? Bgd"
Step 2 - name of unit

This is also pretty easy - just include the following:

^ut^ - unit (eg Archer)

So the code is now:

Naming code = "? Div ? ^ut^ Bgd"
Step 3 - incrementing by type of unit ...

The code contains a bunch of ways of counting (across all units, unit type, city, unit type and city, etc). For this one, we want to use the version that counts across unit. That is:

^cntu[f]^ - count across same unit (increments based on unit)

The number formatting in this case is 'ordinal' which is code 'o'. So, this means that our naming code is now ...

Naming code = "? Div ^cntu[o]^ ^ut^ Bgd"
Step 4 - telling it when to reset back to 1

We want to count up to 5, then loop back to 1. To do this, we need to include a tt1 code(basically telling it when to reset). That is:

^tt1[f][x:y]^ - total where the total is a random number between x and y (number)

Now for this particular name, you don't actually want to display this result. So you need to use the format code for silent ... . This brings our naming code to:

Naming code = "? Div ^cntu[o]^ ^ut^ Bgd ^tt1[5:5]^"

Step 5 - Group counter

This requires a tt2 code. Again, the help file tells us what that is too ...

^tt2[f][x]^ - total count (starts at x, incremented by 1 each time ^tt is reset to 1)

And the naming code is now ...

Naming code = "^tt2[o][1]^ Div ^cntu[o]^ ^ut^ Bgd ^tt1[5:5]^"


I just tried this in game and it was golden :goodjob:
 
Thank you. I will give this a try. I assume I change the 5 to a 10 if I want to start the next group at 10. But how do I stop the Division count at 4?
 
Okay. Something is not working. My Axeman name came out to be

^tt2[o][1]^ Div 4th Axeman Bgd ^tt1[5:5]^

I blocked and copied the line from your post.
 
hmmn - it worked for me. Did you try the in-game name testing option? Try moving the tt1 component to the start.

I just used it in-game and it worked for me ...



 
hmmn - what can I say - it looks ok. Try changing the to an [o] so that it will display.
 
I tried and it just displayed the same with an o as it did with the s. Is there another option I need to have turned on? Also I am using BAT 1.1 does that make a difference?
 
I tried and it just displayed the same with an o as it did with the s. Is there another option I need to have turned on? Also I am using BAT 1.1 does that make a difference?
No - not really. And it is a little hard to debug because that is BUG option specific. Try dropping one of the 'tt' and see what you get.
 
Okay I did a little at a time starting with
^tt1[o][5:5]^ Div
and I got 10th Div

When I added ^cntu[o]^ to the end of the line, I receivied just the format back. I then added ^ut^ to the line and received the format back. So it works at first then goes crazy.
 
Put in the whole code and then send me your 'Unit Naming.ini' file - look under the 'Beyond the Sword\BUG Mod' folder.

ruff.hi at gmail dot com
 
got it - tested it - worked perfectly. Which version of BUG are you using? I don't think we have played with the naming code for a good 12 months.
 
Top Bottom