BTS Unaltered Gameplay Project

Status
Not open for further replies.
Not being much of a python addict, I assume its something to do with building the path to the ini file and mod directory from Elmer's old code for this.

Code:
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)
    assetsPath.insert(1, installActiveModAssetsDir)

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)


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

if __name__ == "__main__": 
    _test()

and the cvmodname workaround...

I tried to hardcode my way into the mod directory but that did not work at all. I get the screen to pop but exit does not seem to work LOL, ill wait for EF to take a look into it.

In totally unrelated good news, it seems that lunar mongoose and crew in the sevopedia thread have made major progress.
I also have regiments "modualized" if we want to use the extended formations.
 
This issue has been solved by someone else. We just need to lift the code.
 
Are you referring to jeckels code in the elmer thread?
 
no. Look at this mod that was uploaded by Gaurav. He modified the way that the mod locates the ini file so that it (the mod) can be placed in either of the mod directories or the customassets directory.
 
I've taken that code and put it into BUG and am testing it now. Unfortunately I need to step out for a few hours, but I'll finish it up when I return. Actually, I'll upload it now so you guys can see if it works for you. My saved game starts up fine, and options are set. Try it in different (mod) locations, please.

Here ya go: Version 0.6

Note that there's a file, CvModName.py, in DrEJlib folder that you'll need to edit so it matches the name of the mod as you set it up.

Code:
#CvModName.py
modName = "BUG Mod 0.5"
 
.06 Placed in My Documents My Games Beyond The Swords Mods
With the CVModName Changed does not work.

Or I'm too alseep to be testing but I think its a matter of it not working. :)
 
Ok yea theres an issue with the directory walking.

Its leaving a null file named BUG Mod.INI
in C:\Documents and Settings\Seth\My Documents\My Games\Beyond the Sword

So its looking at the wrong directory still.

Yea I validated this by dropping in a non null version of BUG Mod.Ini to the my documents my games beyond the sword directory and it works (partially I have a list of ticks that seem to do nothing but till I get a working version no reason to open up other bugs right... I'll regress it when we get this issue fixed cause chances are i'm walking into development area's that have not been hooked up)
 
Its leaving a null file named BUG Mod.INI
in C:\Documents and Settings\Seth\My Documents\My Games\Beyond the Sword

So its looking at the wrong directory still.
Where do you think it should be looking?
 
If you install it as a mod in your My Games folder, it should probably look inside the mod folder for the INI file. What about when you install it as a mod under the main install folder? The CvPath module seems like it should allow us to do any combos. I don't know if you can tell the difference between main install and user folder when it's a mod (or even when custom assets).

In that sense, perhaps looking where it is makes the most sense. Given that the INI is named for the mod, there won't be any conflicts with other mods.
 
Ok, the .ini folder should be in the mod directory. Anywhere else is just asking for errors when the user installs it. Plus if this mod is picked up by other mods (which it already is, for example i'm using it in the composite) it will make the matter much much worse.

The thing is, this was working for warlords, it would do a directory walk looking for the file, and use the last one it see's while there could be a conflict if they had the mod installed in multiple places for the most part that did not happen.

Theres been so many changes done to the ini file routines that its tough for me to determine where the error is. In the Civ Alerts Thread they supposidly have this working I'm not sure what we are doing to break it. But in the ruffmodcontrol.py file it seems like it does another walk, although that may tie in from the DEJ stuff....

Ill pour through the code and see what I Can do...
 
Shoot, I missed a file when I did the merge. I gotta jet, but hopefully replacing RuffModControl.py with the following should fix the issue and make it walk the tree. Sorry about that.

Code:
## RuffModControl.py - used to control access to RuffMod ini file.
## modified from HOF MOD V1.61.001
## Hall of Fame Mod Context
## Used to access Mod Ini file

import os
import os.path
from types import *
from configobj import ConfigObj
import CvUtil
import CvPath
from CvPythonExtensions import *

def get_AutoLog_Path():
    try:
        AutoLogPath = RuffModConfigFile['AUTOLOG']['AutoLogPath']
    except:
        AutoLogPath = CvPath.userDir + '\AutoLog'
    if (AutoLogPath == 'Default'):
        AutoLogPath = CvPath.userDir + '\AutoLog'
    if not os.path.isdir(AutoLogPath):
        os.makedirs(AutoLogPath)
    return AutoLogPath

def read_ConfigFile():
    return ConfigObj(FileName)

def write_ConfigFile():
    RuffModConfigFile.write()
    return

FileName = CvPath.get_INI_File("RuffMod_2w.ini")
RuffModConfigFile = read_ConfigFile()

##----------------------------------------------------------------
class RuffModConfig:
    def __init__(self):
        pass
        
## Private Functions
    def __get_keyvalue(self, section, key, default):
        try: keyvalue = RuffModConfigFile[section][key]
        except: keyvalue = default
        return keyvalue

    def __set_keyvalue(self, section, key, keyvalue):
        RuffModConfigFile[section][key] = keyvalue
        return
    
    def __get_boolkeyvalue(self, section, key, default):
        try: keyvalue = RuffModConfigFile[section].as_bool(key)
        except: keyvalue = default
        return keyvalue
    
## Get Functions
    def get_int(self, section, key, default):
        keyvalue = self.__get_keyvalue(section, key, default)
        try: keyvalue = int(keyvalue)
        except: keyvalue = default
        return keyvalue

    def get_str(self, section, key, default):
        keyvalue = self.__get_keyvalue(section, key, default)
        if not isinstance(keyvalue, StringTypes) : keyvalue = default
        return keyvalue

    def get_boolean(self, section, key, default):
        keyvalue = self.__get_boolkeyvalue(section, key, default)
        if keyvalue == False :
            return False
        elif keyvalue == True :
            return True
        else :
            return default
        
    def get_float(self, section, key, default):
        keyvalue = self.__get_keyvalue(section, key, default)
        try: keyvalue = float(keyvalue)
        except: keyvalue = default
        return keyvalue
    
## Set Functions
    def set_int(self, section, key, keyvalue):
        self.__set_keyvalue(section, key, keyvalue)
        return
        
    def set_str(self, section, key, keyvalue):
        self.__set_keyvalue(section, key, keyvalue)
        return

    def set_boolean(self, section, key, keyvalue):
        self.__set_keyvalue(section, key, keyvalue)
        return

    def set_float(self, section, key, keyvalue):
        self.__set_keyvalue(section, key, keyvalue)
        return
 
Alright, I should have SourceForge up and running with Subversion as the method I'm picking for version posting. I'll set it up with v 0.6, with the above code added. I'm changing version numbers on there slightly to allow for more beta version before release. 0.5 is now 0.05 and 0.6 will be 0.06. I'm sure we're not going to have 99 beta version, but I think this is probably going to go beyond 9 before a full release is made.

Some of the things that Sourceforge offers that we can use for free: Home Page, Forum, Newsletter, task list, and documentation. Since XML isn't being added yet, and my python skills are laughable, I'll work on this the next couple of days, and isa, I'll have it up and running.

https://sourceforge.net/docs/B01/en/#cvs_client - These are the programs you'll need. They'll allow you to retrieve the code, and easily write to the code on the repository. This will make sure we're not writing over each others code.

As soon as I get 0.06 upload with the most current code changes, then PLEASE start using it for code changes... I know it'll be a bit of a PITA at first, but once you get the hang of it, it'll become second nature.
 
Initial Testing Shows no Interface with the above added into
Yes I changed the FileName = CvPath.get_INI_File("RuffMod_2w.ini") line to match the ini file name of the mod.

Code:
load_module CvModName
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "<string>", line 52, in load_module
  File "CvEventInterface", line 13, in ?
  File "<string>", line 52, in load_module
  File "CvCustomEventManager", line 24, in ?
  File "<string>", line 52, in load_module
  File "CvEventManager", line 12, in ?
  File "<string>", line 52, in load_module
  File "CvScreensInterface", line 3, in ?
  File "<string>", line 52, in load_module
  File "CvMainInterface", line 16, in ?
  File "<string>", line 52, in load_module
  File "BugNJAGCOptions", line 5, in ?
  File "<string>", line 52, in load_module
  File "BugOptions", line 5, in ?
  File "<string>", line 52, in load_module
  File "RuffModControl", line 11, in ?
  File "<string>", line 52, in load_module
  File "CvPath", line 116, in ?
  File "CvPath", line 98, in _getUserDir
  File "CvPath", line 106, in _getInstallDir
  File "CvPath", line 86, in __getRegValue
WindowsError: [Errno 2] The system cannot find the file specified
load_module CvAppInterface

I thought I had found the error, chances are this needs to be changed as well though...
In CV Path
The function GetInstallDir is looking for warlords and should be

Code:
def _getInstallDir():
    civ4Dir = __getRegValue(_winreg.HKEY_LOCAL_MACHINE, 
            r"Software\Firaxis Games\Sid Meier's Civilization 4",
            "INSTALLDIR")
    civ4Dir = os.path.join(civ4Dir,"Beyond the Sword")
    return civ4Dir

Just for craps and giggles I put this in my [INSTALL DIRECTORY] Beyond The Sword Mods Folder and tried to load it there...and it does not work either.


Ok further investigation the registry location that jeckel posted the fix for may be incorrect its actually Sid Meier's Civilization 4 - Beyond the Sword

Code:
def _getInstallDir():
    civ4Dir = __getRegValue(_winreg.HKEY_LOCAL_MACHINE, 
            r"Software\Firaxis Games\Sid Meier's Civilization 4  - Beyond the Sword",
            "INSTALLDIR")
    civ4Dir = os.path.join(civ4Dir,"Beyond the Sword")
    return civ4Dir

Testing now....

Dammit to hell...
That gets me past load without errors now it blows up sky high when i go into the options and try to do anything.

Code:
Traceback (most recent call last):

  File "CvOptionsScreenCallbackInterface", line 509, in handleBugCheckboxClicked

  File "BugOptions", line 60, in setBoolean

  File "RuffModControl", line 93, in set_boolean

  File "RuffModControl", line 48, in __set_keyvalue

  File "configobj", line 337, in __getitem__

KeyError: 'RawCommerce'
ERR: Python function handleBugCheckboxClicked failed, module CvOptionsScreenCallbackInterface
Traceback (most recent call last):

  File "CvOptionsScreenCallbackInterface", line 509, in handleBugCheckboxClicked

  File "BugOptions", line 60, in setBoolean

  File "RuffModControl", line 93, in set_boolean

  File "RuffModControl", line 48, in __set_keyvalue

  File "configobj", line 337, in __getitem__

KeyError: 'NJAGCM'
ERR: Python function handleBugCheckboxClicked failed, module CvOptionsScreenCallbackInterface
Traceback (most recent call last):

  File "CvOptionsScreenCallbackInterface", line 509, in handleBugCheckboxClicked

  File "BugOptions", line 60, in setBoolean

  File "RuffModControl", line 93, in set_boolean

  File "RuffModControl", line 48, in __set_keyvalue

  File "configobj", line 337, in __getitem__

KeyError: 'NJAGCM'
ERR: Python function handleBugCheckboxClicked failed, module CvOptionsScreenCallbackInterface
Traceback (most recent call last):

  File "CvOptionsScreenCallbackInterface", line 503, in handleBugExitButtonInput

  File "BugOptions", line 77, in write

  File "RuffModControl", line 29, in write_ConfigFile

  File "configobj", line 1968, in write

IOError: [Errno 2] No such file or directory: ''
ERR: Python function handleBugExitButtonInput failed, module CvOptionsScreenCallbackInterface
Traceback (most recent call last):

  File "CvOptionsScreenCallbackInterface", line 503, in handleBugExitButtonInput

  File "BugOptions", line 77, in write

  File "RuffModControl", line 29, in write_ConfigFile

  File "configobj", line 1968, in write

IOError: [Errno 2] No such file or directory: ''
ERR: Python function handleBugExitButtonInput failed, module CvOptionsScreenCallbackInterface

Alright back to square one as my assumption on the registry key being in error was incorrect...YAY! :)


Wait no...my civ 4 key is civ 4 gold..... so calling registry keys will not work 100%.... as some pay have civ 4 gold and some may have the older civ 4...
 
I'm back and can start looking at this. From the above posting, Ket, I think I understand that I need to sacrifice a goat, and everything should work. ;) Let me see if I can align the stars . . .
 
Ok I tested without the space problem and it blows up in game when i click on or hit exit... it cant find the file to write.....
 
As I posted in the civ4lerts thread, I found the problem. Please see if the fix works for you.
 
Ok since we're done flooding the civ4alerts thread :)

I'll regress the options screen and post results on that, I think Sevopedia is ready for prime time thanks to lunar mongoose's work, and also nevermind and impaler[wrg] posted a series of interface enhancements working under bts that we may want to see if we can use.

http://forums.civfanatics.com/showthread.php?t=235834
 
Ok Just on a quick click test we have python errors with clicking

"Stack Specialist"
"Great Person Research"
"Show Power Rankings"


Spoiler :

Traceback (most recent call last):

File "CvOptionsScreenCallbackInterface", line 509, in handleBugCheckboxClicked

File "BugOptions", line 60, in setBoolean

File "RuffModControl", line 94, in set_boolean

File "RuffModControl", line 49, in __set_keyvalue

File "configobj", line 337, in __getitem__

KeyError: 'Scoreboard'
ERR: Python function handleBugCheckboxClicked failed, module CvOptionsScreenCallbackInterface
Traceback (most recent call last):

File "CvOptionsScreenCallbackInterface", line 509, in handleBugCheckboxClicked

File "BugOptions", line 60, in setBoolean

File "RuffModControl", line 94, in set_boolean

File "RuffModControl", line 49, in __set_keyvalue

File "configobj", line 337, in __getitem__

KeyError: 'Scoreboard'
ERR: Python function handleBugCheckboxClicked failed, module CvOptionsScreenCallbackInterface
Traceback (most recent call last):

File "CvOptionsScreenCallbackInterface", line 509, in handleBugCheckboxClicked

File "BugOptions", line 60, in setBoolean

File "RuffModControl", line 94, in set_boolean

File "RuffModControl", line 49, in __set_keyvalue

File "configobj", line 337, in __getitem__

KeyError: 'City Screen'
ERR: Python function handleBugCheckboxClicked failed, module CvOptionsScreenCallbackInterface
Traceback (most recent call last):

File "CvOptionsScreenCallbackInterface", line 509, in handleBugCheckboxClicked

File "BugOptions", line 60, in setBoolean

File "RuffModControl", line 94, in set_boolean

File "RuffModControl", line 49, in __set_keyvalue

File "configobj", line 337, in __getitem__

KeyError: 'Tech'
ERR: Python function handleBugCheckboxClicked failed, module CvOptionsScreenCallbackInterface
Traceback (most recent call last):

File "CvOptionsScreenCallbackInterface", line 509, in handleBugCheckboxClicked

File "BugOptions", line 60, in setBoolean

File "RuffModControl", line 94, in set_boolean

File "RuffModControl", line 49, in __set_keyvalue

File "configobj", line 337, in __getitem__

KeyError: 'Tech'
ERR: Python function handleBugCheckboxClicked failed, module CvOptionsScreenCallbackInterface
 
I've rebuilt the INI file, adding all missing sections and values. However, I have changed some of them and the options in the Python code, so you'll need both. Give me 10 minutes and I'll post what I have.
 
Status
Not open for further replies.
Back
Top Bottom