[PYTHONCOMP] Random Unit Names

Mmm, it's still not working. I copied everything from inside that spoiler tag and pasted it into a new text file and from there to my event manager file, writing over everything. I also used a comparison tool to check that the .txt file matched the .py file (which it did).
 
From the zip you uploaded it would seem that you have 2 event managers, one in Assets/Python, and one in the mod root directory. The one is Assets/Python is the one being run, and it doesn't seem to have been updated with the indentation fix.
 
The Great Apple said:
From the zip you uploaded it would seem that you have 2 event managers, one in Assets/Python, and one in the mod root directory. The one is Assets/Python is the one being run, and it doesn't seem to have been updated with the indentation fix.

Cheers for the help. That's an outdated zip. This is the python folder that I'm working with, but I'm still not getting random names.

http://www.civfanatics.net/uploads11/python.zip
 
Gotcha.

Okies - I think it is because you've put the code into onUnitBuilt as well as onUnitCreated, but the on in onUnitBuilt won't work, because 'unit' isn't defined - this is throwing an error so it doesn't even get to onUnitCreated. You should be able to get away with deleting the bold bits (but only in the onUnitBuilt method - not onUnitCreated)
Code:
	def onUnitBuilt(self, argsList):
		SevoTraits.checkNewUnit(argsList[1],true)
		self.parent.onUnitBuilt(self, argsList)

		[B]iOwner = gc.getPlayer(unit.getOwner())
		iCivilizationType = iOwner.getCivilizationType()
		unit.setName(RandomNameUtils.getRandomCivilizationName(iCivilizationType))[/B]
 
The Great Apple said:
Gotcha.

Okies - I think it is because you've put the code into onUnitBuilt as well as onUnitCreated, but the on in onUnitBuilt won't work, because 'unit' isn't defined - this is throwing an error so it doesn't even get to onUnitCreated. You should be able to get away with deleting the bold bits (but only in the onUnitBuilt method - not onUnitCreated)
Code:
	def onUnitBuilt(self, argsList):
		SevoTraits.checkNewUnit(argsList[1],true)
		self.parent.onUnitBuilt(self, argsList)

		[B]iOwner = gc.getPlayer(unit.getOwner())
		iCivilizationType = iOwner.getCivilizationType()
		unit.setName(RandomNameUtils.getRandomCivilizationName(iCivilizationType))[/B]


Actually, it should be in both methods. onUnitBuilt be:

Code:
	def onUnitBuilt(self, argsList):
		SevoTraits.checkNewUnit(argsList[1],true)
		self.parent.onUnitBuilt(self, argsList)

		city = argsList[0]
		unit = argsList[1]

		iOwner = gc.getPlayer(unit.getOwner())
		iCivilizationType = iOwner.getCivilizationType()
		unit.setName(RandomNameUtils.getRandomCivilizationName(iCivilizationType))
 
So, what's stopping the mod from working is that I'm missing the part in bold?

Code:
def onUnitBuilt(self, argsList):
		SevoTraits.checkNewUnit(argsList[1],true)
		self.parent.onUnitBuilt(self, argsList)

		[b]city = argsList[0]
		unit = argsList[1][/b]

		iOwner = gc.getPlayer(unit.getOwner())
		iCivilizationType = iOwner.getCivilizationType()
		unit.setName(RandomNameUtils.getRandomCivilizationName(iCivilizationType))
 
zulu9812 said:
So, what's stopping the mod from working is that I'm missing the part in bold?

Code:
def onUnitBuilt(self, argsList):
		SevoTraits.checkNewUnit(argsList[1],true)
		self.parent.onUnitBuilt(self, argsList)

		[b]city = argsList[0]
		unit = argsList[1][/b]

		iOwner = gc.getPlayer(unit.getOwner())
		iCivilizationType = iOwner.getCivilizationType()
		unit.setName(RandomNameUtils.getRandomCivilizationName(iCivilizationType))

sounds like it.
 
onUnitCreated and onUnitBuilt are two different events which often get triggered together, although not always. At the moment you have the code in both, where it only ever need be in one - onUnitCreated if you want it for all your units (starting units & units not built), and onUnitBuilt for only built units. I'm not certain onUnitCreated doesn't trigger when you upgrade a unit though.
 
Goddamitt!

Still not working! Here is the event manager that I am using (including the fix that TheLopez just suggested), although I can't help but think that the problem might lie elsewhere,
 
Right. I have no idea now. Time for plan B!

These ini switches in the main ini file should enable python error popups (change old values to new), which should hopefully say what is going wrong when the naming doesn't work:
Code:
HidePythonExceptions = 0
ShowPythonDebugMsgs = 1
LoggingEnabled = 1
MessageLog = 1
After failing to do the naming a popup should come up, the contents of which should be written to My Docs/My Games/Civ 4/Logs/PythonErr.log. If you post that log up then it should be faily easy to see what is going wrong.

If you don't get a popup, then something more fundamental is wrong (the code isn't being called, or for some reason is being cut). I'm pretty sure you'll get a popup...
 
zulu9812 said:
Goddamitt!

Still not working! Here is the event manager that I am using (including the fix that TheLopez just suggested), although I can't help but think that the problem might lie elsewhere,


zulu9812, What version of the SevoMod are you using?
 
zulu9812 said:
I am using 2.9z
Ah, there's the problem, whenever I run Sevo Mod 2.9z with the debug messages turned on I get an error message myself that says:
AttributeError: RealSlavery instance has no attribute 'playerSlaves'

you might want to comment out all RealSlavery related items in the event manager and see if that resolves it.
 
The Great Apple said:
These ini switches in the main ini file should enable python error popups (change old values to new), which should hopefully say what is going wrong when the naming doesn't work

I wasn't sure which INI file you meant, so I entered them into the mod's ini file (in the mod root directory) and the game's ini file (in the Civ4 directory under My Documents/My Games)

The Great Apple said:
After failing to do the naming a popup should come up, the contents of which should be written to My Docs/My Games/Civ 4/Logs/PythonErr.log. If you post that log up then it should be faily easy to see what is going wrong.

If you don't get a popup, then something more fundamental is wrong (the code isn't being called, or for some reason is being cut). I'm pretty sure you'll get a popup...

No popup :crazyeye:

An error log was found in that directory, but I can't be sure how long the contents have been there. Additionally, the log was called PythonErr2.log. I took a look at it, and I'm probably wrong, but it seemed to indicate a failure to import the entire SevoEventManager. I've attached that log to this post.

TheLopez said:
you might want to comment out all RealSlavery related items in the event manager and see if that resolves it.

I did that, but still no random names. There were 3 instances of RealSlavery - I deleted each line, but left the surrounding module.
 
zulu9812 said:
I wasn't sure which INI file you meant, so I entered them into the mod's ini file (in the mod root directory) and the game's ini file (in the Civ4 directory under My Documents/My Games)
Code:
No popup :crazyeye: 

An error log was found in that directory, but I can't be sure how long the contents have been there. Additionally, the log was called PythonErr[b]2[/b].log. I took a look at it, and I'm probably wrong, but it seemed to indicate a failure to import the entire SevoEventManager. I've attached that log to this post.



I did that, but still no random names. There were 3 instances of RealSlavery - I deleted each line, but left the surrounding module.[/QUOTE]


Please upload your CvEventInterface file.
 
Sure. I took a look at it and the part inbetween #<RUN START> and #<RUN END> looked like it might be interfering with the call for the SevoEventManager, so I deleted it and tried again - but still no luck.
 
zulu,

Are you only trying to combine the random unit mod and the latest release of the Sevo mod?
 
zulu9812 said:
Any updates?
Here you go, I am attaching a new version of the event manager and random unit name utils file.

Just add these to a fresh copy of the Sevo mod and it should work like expected.
 

Attachments

  • SevoModWRUN.zip
    65.7 KB · Views: 112
Top Bottom