Great Person error

I assumed you are getting the same error you got before I said to change it to BugPath. If that's not the case please update with the new stack trace. If that is the case, perhaps you're looking at the wrong file, so post the complete file that has the "szArtPath = ..." line listed in post #54.
 
I assumed you are getting the same error you got before I said to change it to BugPath. If that's not the case please update with the new stack trace. If that is the case, perhaps you're looking at the wrong file, so post the complete file that has the "szArtPath = ..." line listed in post #54.

OK here is the szArtPath, CvGreatPersonScreen.py:

Spoiler :
Code:
## Sid Meier's Civilization 4
from CvPythonExtensions import *
import PyHelpers
import CvUtil
import ScreenInput
import CvScreenEnums
import string
import CvPath
import os.path
import CvGreatPersonModEventManager

# ScS  import the new file that we created with the .bat file
# ScS  import os.path to deal with checking whether files exist.

PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo

# globals
gc = CyGlobalContext()
ArtFileMgr = CyArtFileMgr()
localText = CyTranslator()

# ScS Variable to snage the art Path from the .bat file.

class CvGreatPersonScreen:
	"Great Person Screen"
	
	def __init__(self):

                
		self.X_SCREEN = 255
		self.Y_SCREEN = 40
		self.W_SCREEN = 515
		self.H_SCREEN = 570
		self.Z_BACKGROUND = -1.1
		self.Z_CONTROLS = self.Z_BACKGROUND - 0.2
		self.DZ = -0.2
		

		self.iMarginSpace = 15

		
		self.Y_TITLE = self.Y_SCREEN + 25
		
                self.W_PORTRAIT = 460
		self.H_PORTRAIT = 460
				
		self.X_EXIT = self.X_SCREEN + self.W_SCREEN/2 - 66
		self.Y_EXIT = self.Y_SCREEN + self.H_SCREEN - 50
		self.W_EXIT = 120
		self.H_EXIT = 30
		
		self.PICTURE_BASE = "Art/GreatPeople/%s.dds"
	
	def interfaceScreen (self, iData):

		d = CvGreatPersonModEventManager.g_dict
		pUnit, iPlayer, pCity = d.pop(iData)
		player = gc.getPlayer(iPlayer)
		
		#CvUtil.pyPrint("Great Person Popup: Name:<%s> Player:<%s> City:<%s>"%(pUnit.getNameNoDesc(), player.getName(), pCity.getName()))

		szArtPath = CvPath.getPath(os.path.join("art","GreatPeople"), "Great Person.dds")
		#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 = os.path.join(szArtPath, szImageName + ".dds")
		#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"				


		szPicturePath = str(self.PICTURE_BASE %(szImageName))
		#CvUtil.pyPrint("Great Person Popup: Picture Path: " + szPicturePath)

		screen = CyGInterfaceScreen( "GreatPersonScreen", CvScreenEnums.ERA_MOVIE_SCREEN)
		screen.addPanel("GreatPersonPanel", "", "", true, true,
			self.X_SCREEN, self.Y_SCREEN, self.W_SCREEN, self.H_SCREEN, PanelStyles.PANEL_STYLE_MAIN)
		
		screen.showWindowBackground(True)
		screen.setSound("AS2D_NEW_ERA")
		screen.showScreen(PopupStates.POPUPSTATE_MINIMIZED, False)
                screen.setDimensions(screen.centerX(0), screen.centerY(0), 1024, 768)
                screen.setRenderInterfaceOnly(False)


                
		# Header...
		szHeader = localText.getText("TXT_KEY_MISC_GP_BORN", (szPersonName, pCity.getName()))  #ScS
		szHeaderId = "GreatPersonTitleHeader"
		screen.setText(szHeaderId, "Background", szHeader, CvUtil.FONT_CENTER_JUSTIFY,
			       self.X_SCREEN + self.W_SCREEN / 2, self.Y_TITLE, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
		
		screen.setButtonGFC("GreatPersonExit", localText.getText("TXT_KEY_MAIN_MENU_OK", ()), "", self.X_EXIT, self.Y_EXIT, self.W_EXIT, self.H_EXIT, WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1, ButtonStyles.BUTTON_STYLE_STANDARD )
		
		screen.addDDSGFC("GreatPersonPortrait", szPicturePath, self.X_SCREEN + 27, self.Y_SCREEN + 50, self.W_PORTRAIT, self.H_PORTRAIT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

		return 0
	
	def type2str(self, szUnitType):
		szTemp = szUnitType[5:]
		if szTemp[:6] == "GREAT_":
			szTemp = szTemp[6:]
		return "Great " + szTemp.capitalize() 
		
	# Will handle the input for this screen...
	def handleInput (self, inputClass):
		return 0

	def update(self, fDelta):
		return

now the CvPath.py:

Spoiler :
Code:
## Copyright (c) 2006, Gillmer J. Derge.

## This file is part of Civilization IV Alerts mod.
##
## Civilization IV Alerts mod is free software; you can redistribute
## it and/or modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation; either
## version 2 of the License, or (at your option) any later version.
##
## Civilization IV Alerts mod is distributed in the hope that it will
## be useful, but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
## See the GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Civilization IV Alerts mod; if not, write to the Free
## Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
## 02110-1301 USA

__version__ = "$Revision$"
# $Source$

"""Implements a collection of utility methods and variables for determining
the location of Civilization 4 components.

The following variables are exposed.

* activeModName: the name of the currently active mod or None if no mod has
  been loaded.
  
  NOTE: activeModName does not currently work in a completely automated 
  fashion.  There does not appear to be a way to determine the active mod 
  programmatically from Python code.  A mod that wishes to export its name 
  to this module must create a Python module called CvModName that contains 
  a string variable named modName set to the name of the mod.  A sample 
  CvModName is shown below.

  # CvModName.py
  modName = "Next War Advanced"

  Of course, a CvModName Python module should only be used if the mod is 
  indeed installed in the Mods directory, not when it is installed in 
  CustomAssets.  Furthermore, if the value of the modName variable does not
  correctly match the mod directory name, the path variables will not be
  set properly.

* userDir: the user's Civilization 4 directory, typically
  C:\Documents and Settings\User\My Documents\My Games\Sid Meier's Civilization 4
  
* userAssetsDir: <userDir>\CustomAssets

* userModsDir: <userDir>\Mods

* userActiveModDir: <userDir>\Mods\<activeModName>

* userActiveModAssetsDir: <userDir>\Mods\<activeModName>\Assets

* installDir: the Civilization 4 installation directory, typically
  C:\Program Files\Firaxis Games\Sid Meier's Civilization 4

* installAssetsDir: <installDir>\Assets

* installModsDir: <installDir>\Mods

* installActiveModDir: <installDir>\Mods\<activeModName>

* installActiveModAssetsDir: <installDir>\Mods\<activeModName>\Assets

* assetsPath: a list containing all Assets directories that appear on the
  game's load paths.  Typically [userAssetsDir, installAssetsDir] or
  [userActiveModAssetsDir, installActiveModAssetsDir, userAssetsDir, installAssetsDir]

* pythonPath: a list containing all directories that appear on the
  game's Python load path.  The game's Python module loader does not support
  Python packages, so this list includes not only the Python subdirectory
  of each element of the assetsPath but also all non-empty subdirectories.

"""


import os
import os.path
import sys

if (sys.platform == 'darwin'):
	""" Mac OS X """
	def _getUserDir():
		return os.path.join(os.environ['HOME'], "Documents", "Civilization IV")

	def _getInstallDir():
		import commands
		civ4name = "Civilization IV.app/Contents/MacOS/Civilization IV"
		str = commands.getoutput("ps -xo 'command' | grep " + "'" + civ4name + "'")
		m = str.find(civ4name)
		if (m >= 0):
			installDir = str[0:m]
		return installDir
else:
	import _winreg
	""" Windows """
	def __getRegValue(root, subkey, name):
		key = _winreg.OpenKey(root, subkey)
		try:
			value = _winreg.QueryValueEx(key, name)
			return value[0]
		finally:
			key.Close()
	
	def _getUserDir():
		myDocuments = __getRegValue(_winreg.HKEY_CURRENT_USER, 
				r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders",
				"Personal")
		civ4Dir = os.path.basename(_getInstallDir())
		return os.path.join(myDocuments, "My Games", civ4Dir)
	
	def _getInstallDir():
		#subkey = r"Software\Firaxis Games\Sid Meier's Civilization 4 - Beyond the Sword"
		#dir = __getRegValue(_winreg.HKEY_LOCAL_MACHINE, subkey, "INSTALLDIR")
		#if (not dir):
		#	subkey = r"Software\Firaxis Games\Sid Meier's Civilization 4 Complete"
		#	dir = __getRegValue(_winreg.HKEY_LOCAL_MACHINE, subkey, "INSTALLDIR")
		#return dir
		installDir = os.getcwd()
		print "os.getcwd():  ", installDir
		return installDir


activeModName = None
try:
    import CvModName
    activeModName = CvModName.modName
except:
    pass

userDir = _getUserDir()

userAssetsDir = os.path.join(userDir, "CustomAssets")

userModsDir = os.path.join(userDir, "Mods")

userActiveModDir = None

userActiveModAssetsDir = None

installDir = _getInstallDir()

installAssetsDir = os.path.join(installDir, "Assets")

installModsDir = os.path.join(installDir, "Mods")

installActiveModDir = None

installActiveModAssetsDir = None

assetsPath = [userAssetsDir, installAssetsDir]

if (activeModName != None):
    userActiveModDir = os.path.join(userModsDir, activeModName)
    userActiveModAssetsDir = os.path.join(userActiveModDir, "Assets")
    installActiveModDir = os.path.join(installModsDir, activeModName)
    installActiveModAssetsDir = os.path.join(installActiveModDir, "Assets")
    assetsPath.insert(0, userActiveModAssetsDir)
# YAUGM changes begin
#   assetsPath.insert(1, installActiveModAssetsDir)
    assetsPath.insert(2, installActiveModAssetsDir) # now goes after CustomAssets!
# YAUGM changes end

pythonPath = []
for dir in [os.path.join(d, "Python") for d in assetsPath]:
    for root, subdirs, files in os.walk(dir):
        if (len(files) > 0):
            pythonPath.append(root)

# YAUGM changes begin

# Designed for GreatPersonMod, returns absolute path for
# a relative path to Assets dir if and only if fileName is
# found in the location specified.
# see _test() for example.
def getPath(relPath, fileName):
    for filePath in [os.path.join(d, relPath) for d in assetsPath]:
        if os.path.isfile(os.path.join(filePath, fileName)):
            return filePath
    return ""

# Designed for Ruff's Cobbled SG Modpack 1.2b, returns list
# of potential locations for the ini file. This is called by
# CvConfigParser.py. File locations are listed in reverse
# assetsPath order so that userDir\Mods overrides CustomAssets
# overrides installDir\MODS.
# Use like this: files = CvPath.getINIPathForCvConfigParser("RuffMod.ini")
# Note: CvConfigParser.py is no longer used in Ruff's Cobbled SG Modpack 2.0+,
# but this is still useful for many of TheLopez's mod components.
def getINIPathForCvConfigParser(fileName):
    if (fileName != None):
        filenames = [os.path.join(os.path.dirname(dir), fileName)
                     for dir in assetsPath]
        filenames.reverse()
        return filenames
    return None

# Designed for Ruff's Cobbled SG Modpack 2.0.x(w), return the path
# to an ini file which should be located just outside one of the
# directories in the assets path. This is called from RuffModControl.py
def get_INI_File(szINIFileName):
    filepaths = [os.path.join(os.path.dirname(dir), szINIFileName) 
        for dir in assetsPath]
    for filepath in filepaths:
        if os.path.isfile(filepath):
            return filepath
    return ""

# YAUGM changes end

def _test():
    print "activeModName = " + str(activeModName)
    print "userDir = " + userDir
    print "userAssetsDir = " + userAssetsDir
    print "userModsDir = " + userModsDir
    print "userActiveModDir = " + str(userActiveModDir)
    print "userActiveModAssetsDir = " + str(userActiveModAssetsDir)
    print "installDir = " + installDir
    print "installAssetsDir = " + installAssetsDir
    print "installModsDir = " + installModsDir
    print "installActiveModDir = " + str(installActiveModDir)
    print "installActiveModAssetsDir = " + str(installActiveModAssetsDir)
    print "assetsPath = " 
    for dir in assetsPath:
        print "  " + dir
    print "pythonPath = "
    for dir in pythonPath:
        print "  " + dir

# YAUGM changes begin
    print "greatPeopleArtPath = " + getPath("art\\GreatPeople", "Great Person.dds")
    print "RuffMod.ini location: " + get_INI_File("RuffMod_2w.ini")
    configFilePath = getINIPathForCvConfigParser("")
    configFilePath.reverse()
    print "configFilePath = "
    for filePath in configFilePath:
    	print "  " + filePath
# YAUGM changes end

if __name__ == "__main__": 
    _test()
:confused::crazyeye:

thx for trying to help.
 
Great, and we also need the stack trace showing file and line numbers and error message. I want to make sure it's the same as you posted above or something new.
 
Great, and we also need the stack trace showing file and line numbers and error message. I want to make sure it's the same as you posted above or something new.

See there in-lies the problem, there is no python error, because it does give the "stupid" default dds file of a ?, so it thinks there's no error? But that is bogus:mad:. And as far as stack trace, i have no ideas what that is, sorry.:blush:
 
The problem is that it's simply not finding a file with the great person's name.

1. Have you installed the separate huge archive of images into the correct place? IIRC that's Art/GreatPeople, but please confirm with the full path to a single great person's file.

2. Turn on the debugging information in that file. Everywhere you see this

Code:
#CvUtil.pyPrint(...)

remove that # at the start of the line:

Code:
CvUtil.pyPrint(...)

Test your game again and post the contents of Logs/PythonDbg.log. If you don't have that file in your My Games / BTS folder, look at BUG's Troubleshooting page for instructions to turn logging on. These instructions work with BTS; they are not specific to BUG.
 
Here are the relevant log entries from PythonDbg.log:

Code:
PY:Great Person Popup: Name:<Sojourner Truth> Player:<Jeff> City:<Athens>
[B]PY:CvGreatPersonScreen: szArtPath: [/B]
PY:Great Person Popup: Image Filename: Sojourner Truth.dds
PY:Great Person Popup: Picture Path: Art/GreatPeople/Great Person.dds

The bold line is where it's telling you that it could not find "Great Person.dds" in an asset folder "art/GreatPeople". CvPath supposedly looks in the mod's Assets folder as well as CustomAssets and BTS's Assets folder. Where do you have the images installed?

My guess is that you do not have the correct value for CvModName.modName.

1. Do you have the CvModName.py Python module in your Python folder?

2. What is the value assigned to modName?

Code:
modName = "<some name here>"

3. This value must match your mod's folder name in the BTS/Mods folder exactly. Does it?
 
Here are the relevant log entries from PythonDbg.log:

Code:
PY:Great Person Popup: Name:<Sojourner Truth> Player:<Jeff> City:<Athens>
[B]PY:CvGreatPersonScreen: szArtPath: [/B]
PY:Great Person Popup: Image Filename: Sojourner Truth.dds
PY:Great Person Popup: Picture Path: Art/GreatPeople/Great Person.dds

The bold line is where it's telling you that it could not find "Great Person.dds" in an asset folder "art/GreatPeople". CvPath supposedly looks in the mod's Assets folder as well as CustomAssets and BTS's Assets folder. Where do you have the images installed?

ok my file leading to it is: Art/GreatPeople(including dds files). The ? is a file called Great Person.dds


My guess is that you do not have the correct value for CvModName.modName.

1. Do you have the CvModName.py Python module in your Python folder?

Code:
# CvModName
#
# To register the name of this mod with the config parser

modName = 'Next War Advanced'

2. What is the value assigned to modName?

Code:
modName = "<some name here>"

See above

3. This value must match your mod's folder name in the BTS/Mods folder exactly. Does it?

Name of mod: Next War Advanced


Now heres the WEIRD thing about it,: if i replace the modname with:

Code:
# CvModName
#
# To register the name of this mod with the config parser

modName = 'Beginning'
and place an extra folder OUTSIDE of NWA called Beginning, and have have folders Assets/Art/GreatPeople(dds files here), it works correctly.:crazyeye:
 
Art/GreatPeople/dds files. The ? is a file called Great Person.dds

Is this the full path to the file?

Code:
Next War Advanced/
  Assets/
    Art/
      GreatPeople/
        dds files/
          Great Person.dds

Lines ending in "/" are folders. If so, you have an extra level of folders (dds) that aren't specified in the code. The simplest solution is to move everything from the "dds files" folder up one level to the "GreatPeople" folder and remove the now-empty "dds files" folder.

My guess is that this was a ZIP archive that you unpacked, keeping the name of the archive as the new folder to hold the files. The mod is designed to have all the "*.dds" files directly in the "GreatPeople" folder.
 
Is this the full path to the file?

Code:
Next War Advanced/
  Assets/
    Art/
      GreatPeople/
        dds files/
          Great Person.dds

Lines ending in "/" are folders. If so, you have an extra level of folders (dds) that aren't specified in the code. The simplest solution is to move everything from the "dds files" folder up one level to the "GreatPeople" folder and remove the now-empty "dds files" folder.

My guess is that this was a ZIP archive that you unpacked, keeping the name of the archive as the new folder to hold the files. The mod is designed to have all the "*.dds" files directly in the "GreatPeople" folder.

OK i must have wrote it wrong, they are all in the GreatPeople folder, it Assets/Art/GreatPeople(including the dds files) also you wrote as the same time i did, also look at the last statement i did in last post.
 
Triple-check that the value inside the quotes assigned to modName matches exactly the name of the mod's folder. That it works with "Beginning" is a sure sign that the names don't match exactly.
 
Triple-check that the value inside the quotes assigned to modName matches exactly the name of the mod's folder. That it works with "Beginning" is a sure sign that the names don't match exactly.

Now there in-lies the real problem i believe. Heres what i did, I copied the name (Next War Advanced) not in quotes of course), from the mod folder, and pasted it there to the cvmodname, so it cant be wrong?:confused:

It is driving me :crazyeye:
 
Perhaps CvPath doesn't like having spaces in the mod's name? Try renaming your mod folder to "NextWarAdvanced" and changing it in CvModName.
 
Perhaps CvPath doesn't like having spaces in the mod's name? Try renaming your mod folder to "NextWarAdvanced" and changing it in CvModName.

Nope, i changed the CvPath/CvModName/ and the mod name itself, and still get a ?
 
Welp, I have no clue at this point. Using a different mod name as you did worked, so I don't know why using a different different mod name doesn't work also. :confused: Put it down for a few days and I bet the answer will come to you.
 
Welp, I have no clue at this point. Using a different mod name as you did worked, so I don't know why using a different different mod name doesn't work also. :confused: Put it down for a few days and I bet the answer will come to you.

I doubt it, i have been trying this stuff since Jul:mad::mad::mad:
 
It seems you've worked through a lot of coding problems in that time. Don't let one defeat you or get you down. Just leave the Great Person mod out of your mod for a while.

Seriously, if changing the mod name and folder to Beginning worked, there must be something amiss with using "Next War Advanced." Try something like "sdfkjk" or "MyNextWar".
 
It seems you've worked through a lot of coding problems in that time. Don't let one defeat you or get you down. Just leave the Great Person mod out of your mod for a while.

Seriously, if changing the mod name and folder to Beginning worked, there must be something amiss with using "Next War Advanced." Try something like "sdfkjk" or "MyNextWar".

I think you miss took what i said, i used a COMPLETELY different folder, so i had TWO mod folders, one NWA the other Beginning. And in the Beginning folder i had Assets/Art/GreatPeople(including the dds files here). But then i changed just the Cvmodname to Beginning and the darn thing works correctly:crazyeye: Now that is weird that it reads from another completely different mod folder OUTSIDE of the real mod:confused: So in the last upload i made, i had TWO main folders for the mod folder, as i sated above, just plain weird. :sad:
 
Yes, I understood that. When you point to a folder, it doesn't matter where it is as long as you have the correct path. ZIP up your entire mod folder and post it.
 
Yes, I understood that. When you point to a folder, it doesn't matter where it is as long as you have the correct path. ZIP up your entire mod folder and post it.

Just look at the signature, i have a copy there, i made alot of changes to the new one, but all in all it still has the same python files.

btw, Thx for always trying to help out!;)
 
Back
Top Bottom