Great Person error

OK now to a different GP stuff i am doing with BUG ok, but i STILL need the above stuff for a DIFFERENT mod, thx.

I dont know how to set this up?

Spoiler :
Code:
## Changes:
## - add GreatPersons mod
##

from CvPythonExtensions import *
import CvEventInterface
import CvUtil
import Popup as PyPopup
import SdToolKit
import PyHelpers
#try:
#	import cPickle as pickle
#except:
#	import pickle
import CvGameUtils
import BugOptions
import BugCore
import BugUtil
import OOSLogger
import PlayerUtil
#import autolog

# BUG - Mac Support - start
BugUtil.fixSets(globals())
# BUG - Mac Support - end

gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo
PyCity = PyHelpers.PyCity
PyGame = PyHelpers.PyGame

# --------- GreatPersonMod BTS -------------
import CvGreatPersonModEventManager

class GPEventManager:
	def __init__(self, eventManager):

		
# --------- GreatPersonMod BTS ------------------
		CvGreatPersonModEventManager.CvGreatPersonModEventManager(eventManager)



I got this in the Logs?

Spoiler :
Traceback (most recent call last):
File "BugConfig", line 99, in unknown_starttag
File "BugConfig", line 326, in startChild
ConfigError: Element <events> does not accept child <events>
Traceback (most recent call last):
File "BugConfig", line 99, in unknown_starttag
File "BugConfig", line 326, in startChild
ConfigError: Element <None> does not accept child <init>
Traceback (most recent call last):
File "BugConfig", line 77, in parse
File "e:/main/civilization4/warlords/assets/python/system\xmllib.py", line 171, in feed
File "e:/main/civilization4/warlords/assets/python/system\xmllib.py", line 268, in goahead
File "BugConfig", line 119, in handle_data
AttributeError: 'NoneType' object has no attribute 'addText'
Traceback (most recent call last):

File "CvAppInterface", line 69, in preGameStart

File "BugEventManager", line 337, in fireEvent

File "BugEventManager", line 347, in _dispatchEvent

File "BugEventManager", line 398, in _handleInitBugEvent

File "BugEventManager", line 558, in initBug

File "BugInit", line 48, in init

File "BugInit", line 69, in loadMod

File "BugConfig", line 77, in parse

File "e:/main/civilization4/warlords/assets/python/system\xmllib.py", line 171, in feed

File "e:/main/civilization4/warlords/assets/python/system\xmllib.py", line 268, in goahead

File "BugConfig", line 119, in handle_data

AttributeError: 'NoneType' object has no attribute 'addText'
ERR: Python function preGameStart failed, module CvAppInterface
:blush:
 
The error message is

ConfigError: Element <events> does not accept child <events>​

Your config XML has an error. Perhaps you're missing the / before the > on an

<events .../>​

line? PythonDbg.log should tell you the XML file name and line number.
 
OK heres what i have:

23:15:54 TRACE: BugConfig - failure parsing C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Rise of Mankind\Assets\Config\init.xml at line 111
23:15:54 TRACE: Element <events> does not accept child <events>

<events module="GPEventManager"> </events> listed in above post?


"PythonErr":
Traceback (most recent call last):
File "BugConfig", line 99, in unknown_starttag
File "BugConfig", line 326, in startChild
ConfigError: Element <events> does not accept child <events>
Traceback (most recent call last):
File "BugConfig", line 99, in unknown_starttag
File "BugConfig", line 326, in startChild
ConfigError: Element <None> does not accept child <init>
Traceback (most recent call last):
File "BugConfig", line 77, in parse
File "e:/main/civilization4/warlords/assets/python/system\xmllib.py", line 171, in feed
File "e:/main/civilization4/warlords/assets/python/system\xmllib.py", line 268, in goahead
File "BugConfig", line 119, in handle_data
AttributeError: 'NoneType' object has no attribute 'addText'
Traceback (most recent call last):

File "CvAppInterface", line 62, in onLoad

File "CvEventInterface", line 30, in onEvent

File "BugEventManager", line 342, in handleEvent

File "BugEventManager", line 347, in _dispatchEvent

File "BugEventManager", line 398, in _handleInitBugEvent

File "BugEventManager", line 558, in initBug

File "BugInit", line 48, in init

File "BugInit", line 69, in loadMod

File "BugConfig", line 77, in parse

File "e:/main/civilization4/warlords/assets/python/system\xmllib.py", line 171, in feed

File "e:/main/civilization4/warlords/assets/python/system\xmllib.py", line 268, in goahead

File "BugConfig", line 119, in handle_data

AttributeError: 'NoneType' object has no attribute 'addText'
ERR: Python function onLoad failed, module CvAppInterface
 
When posting a specific line, please always post some context for it: a few lines (5, 10?) above and below really help. In this case I really need to see the line right before this one.
 
When posting a specific line, please always post some context for it: a few lines (5, 10?) above and below really help. In this case I really need to see the line right before this one.

Thats because its just an ordinary event line in the above it, i believe it has something to do with what i have posted above in the Dec 04 posting the first spoiler. Post #81.

But anyways here is the lines for it:

Code:
</init>
	<event type="LanguageChanged" module="ColorUtil" function="createColors"/>
	
	<events module="DealUtil" function="addEvents"/>
	<events module="DiplomacyUtil" function="addEvents"/>
	<!-- Next War Advanced -->
	<events module="SubdueAnimals">	</events>
	<events module="Militia">	</events>
	<events module="Espionage">	</events>
	<events module="WarriorsOfGod">	</events>
	<events module="NukeAfterEffects">	</events>
	<events module="WarPrizes">	</events>
	<events module="CvEnhancedTechConquestEventManager">
	[B]<events module="GPEventManager">	</events>[/B]
	</events>
	<!-- Next War Advanced end -->
	<init module="GGUtil"/>
	<init module="GPUtil"/>
	<init module="ReligionUtil"/>
	<init module="TechUtil"/>
	<init module="TradeUtil"/>
	<init module="TraitUtil"/>
	<init module="UnitUtil"/>
    <gameutils module="WidgetUtil" handler="getWidgetHelp"/>

	<event type="OnLoad" module="CvTechChooser" function="resetTechPrefs"/>
	<event type="GameStart" module="CvTechChooser" function="resetTechPrefs"/>
 
Yup, this is the problem: You have one <events> including inside another <events>:

Code:
	<events module="CvEnhancedTechConquestEventManager">
	<events module="GPEventManager">	</events>
	[B]</events>[/B]

Either move the last line up

Code:
	<events module="CvEnhancedTechConquestEventManager">	[B][COLOR="Red"]</events>[/COLOR][/B]
	<events module="GPEventManager">	</events>

or use the simpler form like this:

Code:
	<events module="CvEnhancedTechConquestEventManager"[B][COLOR="Red"]/[/COLOR][/B]>
	<events module="GPEventManager"[B][COLOR="Red"]/[/COLOR][/B]>

In XML if you have an element that doesn't contain any other elements you can close it inside the opening tag so you don't need a closing tag:

Code:
<element attr1="a" attr2="b" . . . attrN="z"/>
 
OK now that is is over, here is what i get in the BUG mod i am working on still:

Traceback (most recent call last):

File "CvScreensInterface", line 274, in showGreatPersonScreen

File "CvGreatPersonScreen", line 79, in interfaceScreen

Spoiler :
Code:
# if the name is the empty string, then create a new, generic name from the unit type.
		if szPersonName == "" :
			szPersonName = self.type2str(szUnitType)

		szImageName = szPersonName

		# if there is a file in the GreatPeople directory with the name, we'll load it.
		[B]szImageFilename = os.path.join(szArtPath, szImageName + ".dds")[/B]
		#CvUtil.pyPrint("Great Person Popup: Image Filename: " + szImageFilename)
		if not os.path.isfile(szImageFilename):
                        #if not, load the great "type of person" file
			szImageName = self.type2str(szUnitType)
			szImageFilename = os.path.join(szArtPath, szImageName + ".dds")
			if not os.path.isfile(szImageFilename):
                                #if not, load the great person file
				szImageName = "Great Person"

File "C:\Python24\Lib\ntpath.py", line 90, in join
assert len(path) > 0



TypeError: len() of unsized object

ERR: Python function showGreatPersonScreen failed, module CvScreensInterface


Here is the line i used: perhaps the cause:

Code:
#CvUtil.pyPrint("Great Person Popup: Name:<%s> Player:<%s> City:<%s>"%(pUnit.getNameNoDesc(), player.getName(), pCity.getName()))

		[B]szArtPath = BugPath.findAssetFile("Great Person.dds", os.path.join("Art","GreatPeople"))[/B]

		#CvUtil.pyPrint("CvGreatPersonScreen: szArtPath: " + szArtPath)
 
The code you used to set szArtPath looks correct; I assume it's what I posted above, right? Post your PythonDbg.log file as it should have some useful info in it. What's happening is that it is not finding that file in the subfolder you specified. You used the right names there, so either the files are not in the right place, or it's not finding your mod's folder. PythonDbg.log should tell me which.
 
Hello, I'm picking up this abandoned thread because I'm attempting to do the same thing as StratOnly was doing... get the great people mod going.

I've followed this thread and used your suggestion for szartpath
Code:
		szArtPath = BugPath.findAssetFile("Great Person.dds", os.path.join("Art","GreatPeople"))

I checked the debug log and its saying this:
Code:
PY:CvGreatPersonScreen: szArtPath: C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Destiny\Assets\Art\GreatPeople\Great Person.dds

which is one great person.dds too many in the path. I'm getting the popup, just with the generic greatperson.dds, I'll bet that was strategyonly's problem when he was into this as well.

I'm attempting to fix the hosed path through a bit of trial and error. Feel free to post the correct code first... :D
 
Time for bed whew.

Anyway here's what I got so far...

Code:
		#CvUtil.pyPrint("Great Person Popup: Name:<%s> Player:<%s> City:<%s>"%(pUnit.getNameNoDesc(), player.getName(), pCity.getName()))
		#szArtPath = BugPath.getModDir() + os.path.normpath('/Art/GreatPeople/') 
		szArtPath = BugPath.getModDir() + '\\Art\GreatPeople\\'
		CvUtil.pyPrint("CvGreatPersonScreen: szArtPath: " + szArtPath)

		szPersonName = pUnit.getNameNoDesc()

		# szUnitType will be UNIT_PROPHET, UNIT_MERCHANT, UNIT_ARTIST, etc.
		szUnitType = gc.getUnitInfo(pUnit.getUnitType()).getType()

		# if the name is the empty string, then create a new, generic name from the unit type.
		if szPersonName == "" :
			szPersonName = self.type2str(szUnitType)
		szImageName = szPersonName

		# if there is a file in the GreatPeople directory with the name, we'll load it.
		szImageFilename = szArtPath + szPersonName + ".dds"
		CvUtil.pyPrint("Great Person Popup: Image Filename: " + szImageFilename)
		#szArtPath = BugPath.findAssetFile("Great Person.dds", os.path.join("Art","GreatPeople"))
		if not os.path.isfile(szImageFilename):
                        #if not, load the great "type of person" file
			szImageName = self.type2str(szUnitType)
			szImageFilename = os.path.join(szArtPath, szImageName + ".dds")
			if not os.path.isfile(szImageFilename):
                                #if not, load the great person file
				szImageName = "Great Person"

Everything seems to be working up to the point it defaults to the default. I compared the cvutilpyprints of quotcapita (working) and my mod and the output is identical after having replaced the paths stuff as I did above (see bottom this post).

Anyways it's finding this test to be true and defaults to the regular gp pic.

Code:
			if not os.path.isfile(szImageFilename):
                                #if not, load the great person file
				szImageName = "Great Person"

edit: compare mine output:
Code:
PY:CvGreatPersonScreen: szArtPath: C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Destiny\Art\GreatPeople\
PY:Great Person Popup: Image Filename: C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Destiny\Art\GreatPeople\James Watt.dds
PY:Great Person Popup: Picture Path: Art/GreatPeople/Great Person.dds
vs.
quotcapitas
Code:
PY:CvGreatPersonScreen: szArtPath: C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Quot Capita\Assets\art\GreatPeople
PY:Great Person Popup: Image Filename: C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Quot Capita\Assets\art\GreatPeople\Marie Curie.dds
PY:Great Person Popup: Picture Path: Art/GreatPeople/Marie Curie.dds
 
I'll ask the obvious: have you checked that those art files are in the location specified in the log message?
 
This doesn't seem to work, if you check the code I had to change the calls like this earlier in the code to get it as far as it goes now.
Code:
			if not os.path.isfile(szImageFilename):
                                #if not, load the great person file
				szImageName = "Great Person"

It needs bugatized something like this:
Code:
BugPath.findAssetFile(szImageName, os.path.join("Art","GreatPeople"))
 
edit: compare mine output:
Code:
PY:CvGreatPersonScreen: szArtPath: C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Destiny\Art\GreatPeople\
PY:Great Person Popup: Image Filename: C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Destiny\Art\GreatPeople\James Watt.dds
PY:Great Person Popup: Picture Path: Art/GreatPeople/Great Person.dds
vs.
quotcapitas
Code:
PY:CvGreatPersonScreen: szArtPath: C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Quot Capita\Assets\art\GreatPeople
PY:Great Person Popup: Image Filename: C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Quot Capita\Assets\art\GreatPeople\Marie Curie.dds
PY:Great Person Popup: Picture Path: Art/GreatPeople/Marie Curie.dds

You are missing the "Assets" part of the path that should be between "Destiny" and "Art".
 
Right you are... Nice catch! That's what I get for trying to mess with python in the wee hours of night!

It seems to be working now

If its working correctly can i get a copy of it, thx.
 
Here you go.

Strat. you should only need the CvGreatPersonScreen.py file but I included all the affected python anyways. Let me know if it works for you or not but it sounded like you were having the same issues I was getting this to work - it wasn't finding the right files.

Anyone else, please note this is for a bug based install, since there is a call to a BUG function and it won't.

it needs the picture files under <bts>\<mod>\assets\art\greatpeople\
 

Attachments

Back
Top Bottom