Unit Naming

Ruff, had a look into your most excellent coding *ruffles Ruff_hi ears*

Is this the code set I'd need to change

Code:
 def getTotal1(self, conv):

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



#		return 'not found' indicator

		ziStart = conv.find("^tt1[")

		if (ziStart == -1):

			return -1



#		locate and extract the 'low' value

		ziStart = conv.find("[",ziStart)

		ziStart = conv.find("[",ziStart + 1)

		ziEnd = conv.find(":",ziStart)

		ziLow = int(conv[ziStart + 1:ziEnd])

		if (ziLow < 1): ziLow = 1



#		locate and extract the 'high' value

		ziStart = ziEnd

		ziEnd = conv.find("]",ziStart)

		ziHigh = int(conv[ziStart + 1:ziEnd])

		if (ziHigh < 1): ziHigh = 1



#		check that the user isn't an idiot

		if (ziLow > ziHigh): return ziLow



#		return the value

		return random.randint(ziLow, ziHigh)

So if I understand it correctly, I just need to edit the last bit of coding to
Code:
      return(ziLow, ziHigh)

This will eliminate the random number generator, but still retain your :thumbsup: :worship: coding.

Code:
check that the user isn't an idiot

Hey Bad Ruff_Hi, Very naughty

C:/...Path to Beyond the sword Mod.../Assets/Python/Contrib/UnitNameEventManager.py

This is the files address in the Mod I need to amend??
 
C:/...Path to Beyond the sword Mod.../Assets/Python/Contrib/UnitNameEventManager.py

This is the files address in the Mod I need to amend??
Yes - depending on what you are trying to do.
 
Code:
 def getTotal1(self, conv):
...
#		check that the user isn't an idiot
		if (ziLow > ziHigh): return ziLow
I was reading over the code earlier today to answer your questions and I also saw this part ... had to laugh at myself with the comment.
 
ok I've had a look at it a bit of a think and tinkered.

Tried 2 things, both don't work.

1st
Spoiler :

1st 6 trials worked for Squad, great. :goodjob:
BUT, it started at foxtrot company and not Able !!!​


But on 7th unit, when it should reset tt1

Spoiler :


Oh yeah, that error, I said I had, I think I need to build a new unit when ever I restart the game and try unit numbering, having previously build units in a prior save won't do it. Built another new unit, and it worked, didn't build a unit and got error.

Hmm 1st was removed randomint completely from line at end of return the value, no.. Hmmm ok I need to give it a value, it needs and interger so added int back (for interger)

Didn't work either. Double :hmm:

Zoh, its not resetting tt1, why is it so 'Professor Julius Sumner Miller'..."Watch the egg, watch the egg" (oh my god I'm old!!!!!)

had a look and thought this may be problem, but can't quite see way around it.

Spoiler :


Seems to me, that the High Value for tt1 is being incorrectly extracted. It's just giving the highest number for both.

eg I have unit naming convention [party] ^cnt[o]^ Squad, ^tt1[p][1:6]^ Company, ^tt2[r][1]^ Division of the 1st Army.

I get;

1st Squad, Foxtrot Company, I Division of the 1st Army
2st Squad, Foxtrot Company, I Division of the 1st Army
3rd Squad, Foxtrot Company, I Division of the 1st Army
4th Squad, Foxtrot Company, I Division of the 1st Army
5th Squad, Foxtrot Company, I Division of the 1st Army
6th Squad, Foxtrot Company, I Division of the 1st Army

Then is spits out Python errors

So starts at 6 (highest Number) and won't reset.


I have unit naming convention [party] ^cnt[o]^ Squad, ^tt1[p][1:6]^ Company, ^tt2[r][1]^ Division of the 1st Army.

with randomint (ziLow, ziHigh)

I'd get Alpha with 1 squad, Gamma with 3, Epsilon with 5, etc with a corresponding increase in divisions for each company change, partly what I'm after.

I'll use the silent (s) function on tt1 to fix this, but to fix code??

so its correctly reading ziLow and ziHigh, and assigning a random number and reseting once its reached.

Seems to me, it works this way. With Return int (ziLow, ziHigh)

1) Extracts ziLow, in my example its 1.
2) ziStart = ziEnd
3) Exstracts ziHigh, in my example its 6
4) returns the values of (6,6) for ziLow and ziHigh

Solution

Code:
ziStart = ziEnd

        ziEnd = conv.find("]",ziStart)

Change to read

Code:
 ziStart = conv.find(":",ziStart)

        ziStart = conv.find(":",ziStart + 1)

        ziEnd = conv.find("]",ziStart)

Am I even close..or just way way off base.
 
Last edited:
After having more of a play around with it, breaking it totally, and having to re-install a pristine copy of the UnitNameEventManager.py

I've found that the unit testing, for 1 city only, only works for codes of r=t,u all others will just stay at initial value.

As well, if you change the tt1 coding, you need to close the unit name tester, and restart it for that change to take effect.

My current tested code is

Code:
 ^cnt[o][t]^ Squad, ^tt1[s][6:6]^ ^tt2[p][1]^ Company, ^ct^ I Division of the Ancient Era Army

Further it seems to be ignoring the end part of the tt2 function, it just counts by 1, even if you change it to 3, 6 or any other number. Omit it entirely, and it has no effect. Note, this was only for the unit name testing, in actual game play, it'll give a python error if this value is missing, re-installing it, removes said error.

Playing to trial out the t function, I assume its correct, but will test.
 
ok I've had a look at it a bit of a think and tinkered

...

Am I even close..or just way way off base.
I have no idea what you are trying to do so it is hard to say if you are close or not. If you are trying to mod the current system to generate a counter like you have previously desired (ie 1st Platoon, 2nd Squad, Alpha Regiment, 101st Army) then you are way off and it is better to start again (see below).
Zo, its not resetting tt1, why is it so 'Professor Julius Sumner Miller'..."Watch the egg, watch the egg" (oh my god I'm old!!!!!)
Here is a quiz to gauge your age: Who is Ron Barassi?
A1: 'A great football player' (selecting this indicates that you are old ... very old!)
A2: 'A great football coach' (selecting this indicates that you about my age ... a perfect age)
A3: 'Who?' (selecting this indicates that you are a young whipper snapper ... or that you don't live in Melbourne)

As I indicated previously, we did brain storm a way of getting unlimited counters in unit names ...
here is my preliminary thoughts ...

add a counter control somewhere in the naming code ... something like this ...

{5,[2:5,6:10,x,y],[5:5,10:10],[2:2,4:4],[1:1,10:15],[101:101]}

translation

  • {5,...} means there are 5 counters
  • {...,[2:5,6:10,x,y],...} means that the 1st counter starts at a random number between 2 and 5 and counts up to another random number between 6 and 10, it counts over 'x' (same type of code as previous, city, combat type, city & combat type, etc) with special code 'y' so you can tell spears from axes
  • {...,[5:5,10:10],...} means that the 2nd counter starts at a random number between 5 and 5 and counts up to another random number between 10 and 10, it gets incremented once the 1st counter exceeds its max
  • {...,[2:2,4:4],...} means that the 3rd counter starts at a random number between 2 and 2 and counts up to another random number between 4 and 4, it gets incremented once the 2nd counter exceeds its max
  • {...,[1:1,10:15],...} means that the 4th counter starts at a random number between 1 and 1 and counts up to another random number between 10 and 15, it gets incremented once the 3rd counter exceeds its max
  • {...,[101:101]} means that the 5th counter starts at a random number between 101 and 101 and just keeps increasing, it gets incremented once the 4th counter exceeds its max

The balance of the naming code would tell you where to put each counter ...

"Group ct1[f], ct2[f] Div, etc"

where ct1 represents counter 1, ct2 represents counter 2, etc and the [f] controls the formatting.
... why don't we try and code this system into the existing code?
 
To do this, I would start with the following ... change this ...

Code:
#		check if there are any more codes to swap out, return if not
		counters = BugData.getGameData().getTable(SD_MOD_ID)
		while zsName.find("^cnt") != -1:
#			determine what I am counting across
			zsSDKey = self.getCounter(zsName)

...

#			swap out the count code items for count value
			zsName = self.swapCountCode(zsName, "^cnt", ziCnt)
			zsName = self.swapCountCode(zsName, "^tt1", ziTT1)
			zsName = self.swapCountCode(zsName, "^tt2", ziTT2)

... to this ...
Code:
#		check if there are any more codes to swap out, return if not
		counters = BugData.getGameData().getTable(SD_MOD_ID)

		if self.NewCountCodeExists(zsName)
			szName=self.doNewCountCode(zsName)
		else:
			szName=self.doOldCountCode(zsName)

	def NewCountCodeExists(self, zsName):
		return zsName.find("^{") != -1:

	def doNewCountCode(self, zsName):   # you might need to pass some other parameters
		# need new code here

	def doOldCountCode(self, zsName):   # you might need to pass some other parameters
		while zsName.find("^cnt") != -1:
#			determine what I am counting across
			zsSDKey = self.getCounter(zsName)

...

#			swap out the count code items for count value
			zsName = self.swapCountCode(zsName, "^cnt", ziCnt)
			zsName = self.swapCountCode(zsName, "^tt1", ziTT1)
			zsName = self.swapCountCode(zsName, "^tt2", ziTT2)
 
Great Player = Historically I know. (went from Melbourne Captain, to Carlton Captain/Coach= Huge Scandal at the time)
Great Coach = North Melbourne in 70's (I'm Hawthorn, '75 never forget, never forgive. RIP No 5 little champ)
Who is he??? = That bloke assaulted at Nimben NSW

Trouble is, I remember watch Professor Julius on the ABC doing his science specials as a young lad, in the 70's, he made it all seem so interesting to a >10Yr old. Cadbury adds came later.

Why are you so Hot to trot on Random numbers, why not, and I know its more coding, have an option for random numbers f(x) and fixed counting.

I do realize its your personal favourate, and your doing the coding.

That suggestion of (s) for tt1 worked perfectly for the counter, thanks Ruff_Hi tt1(s)(5:5) counts 5 squads, for each company, and then counts infinite companies, (well cycles over at Zulu)

Interesting that the cnt(t,u) only works and not for the other options. I did only test in name testing, but I assume its the same for game play. (I forgot to reset, got caught up in play)

eg
cnt(o)(c) Squad,.... only gives 1st Squad, Alpha Company...1st Squad, Alpha Company...1st Squad, Alpha Company...
cnt(o)(a)...
cnt(o)(b)...
cnt(o)(d)...
all gave same result in unit naming test.

I will test in actual play today...
 
Great Player = Historically I know. (went from Melbourne Captain, to Carlton Captain/Coach= Huge Scandal at the time)
Great Coach = North Melbourne in 70's (I'm Hawthorn, '75 never forget, never forgive. RIP No 5 little champ)
Who is he??? = That bloke assaulted at Nimben NSW

Trouble is, I remember watch Professor Julius on the ABC doing his science specials as a young lad, in the 70's, he made it all seem so interesting to a >10Yr old. Cadbury adds came later.
Seems we are about the same age.
Why are you so Hot to trot on Random numbers, why not, and I know its more coding, have an option for random numbers f(x) and fixed counting.

I do realize its your personal favourate, and your doing the coding.
Nice option, costs nothing in the coding and can be overcome by saying 'random number between x and x'.
Interesting that the cnt(t,u) only works and not for the other options. I did only test in name testing, but I assume its the same for game play. (I forgot to reset, got caught up in play)
I wasn't sure what you meant by this until I said that you didn't play test it. That rings a bell ... remember that the options are ...
copied from the python code said:
## - ^cnt[f][r]^ - counting code, if the code isn't there - return 'ALL'
## - where
## - r = 'a' means count across all units (just increments)
## - r = 'u' means count across same unit (increments based on unit)
## - r = 'c' means count across same city (increments based on city)
## - r = 't' means count across same unit / city (increments based on unit / city)
## - r = 'b' means count across same combat type (increments based on combat type)
## - r = 'd' means count across same domain (increments based on domain)
## - r = other, means count across units that have the same code
... so when you are 'testing' your naming convention using that dialog box, there is no way to tell the code which city it comes from ... so all of the ones using city either ignore the city or use the capital (ie the same city) ... so they look just like the ones based on units only.
 
why don't we try and code this system into the existing code?
So ... do you want to try and code this 'unlimited counter' option into the code? Do you want to lead the coding or be a tester? If you elect testing, then I cannot guarantee very quick turn around ... in fact, I can guarantee very slow turn around.
 
On the unit naming convention :blush:

It seems each convention has its own distinct memory counter, and when you change a counter, it double counts 1 then moves on to the next unit.

Eg, 1,1,2,3,4,5,6,1,2,...... for cnt(f)(6:6), note didn't go over the cycle. only went as far as 3 builds for different counters.

On the coding change, I guess, if I'm going to suggest it, its the least I could do, besides, I want to have a go at Merging REVDCM 2.90 into RAND 2.65 (Beta 5, alpha 1) might even have a go at CLEANING UP ERROR ONLY. No new coding (beyond my abilities) Its my Mod of obsession at moment (6 months ongoing)

RUFF_HI I'll try your suggestions, yeah random (x:x), random (y:y) is easy solution for fixed counter.
 
Sorry Ruff, I just don't have the motivation or the expertise to do it.

I'm actually quite happy with the work around we've made up, sorry, I just don't have the cognitive resources to do coding.

Personally I'd leave it as is. I just like to tinker with ridiculous naming conventions, probably 99% of users would just use the default, or some minor city notifications.

Thanks for offer of assistance, but its really beyond my skills, motivation and educational training.
 
np - I will put this on my back burning and knock something up over the next 3-6 months. I'll post something here so that you can test it.
 
You need "Unit Naming.xml" from the Config folder plus RandomNameUtils.py, Roman.py, and UnitNameEventManager.py from Python/Contrib. You'll need to check the imports of those Python modules to make sure you have all the necessary BUG Core modules as well. For the options screen you'll need BugUnitNameOptionsTab.py from Python/BUG/Tabs plus add it to your main options screen. Finally, include "Adv Unit Naming.ini" from the UserSettings folder so players can thoroughly customize their names if they want to go to that level. If your mod adds new unit/class types, you should modify this file by adding them. Just follow the pattern.

If your mod modifies the available eras, you'll need to modify the config file to make the options in line with them. You need one line for each era like below:

Code:
<option id="Combat_MELEE" key="CombatMELEE" 
        type="string" default="DEFAULT"/>

You'll also need to modify the options screen tab as well, having one line per era like this:

Code:
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_MELEE")

I think that's it. If you have any trouble, post again with the debug and error logs.
 
Hello, I got to this thread from the Search button. I'm using Rise of Mankind - A New Dawn, which has BUG and the Unit Naming component.

My question is: is it possible to name a certain unit type (e.g. Wooden Ships, but not all water units) with names from a user defined list?
Similarly to how Great People get individual names for each GP type.
 
Top Bottom