Help Merging Python Files (BUG + X)

Lib.Spi't

Overlord of the Wasteland
Joined
Feb 12, 2009
Messages
3,708
Location
UK
hi guys, I am trying to figure out what I will need to do to merge python content into my mod based on K-mod/BUG code.

I am having trouble figuring out how to go about it though.

I think I have to use the BUGgameutil file.

I am just having trouble getting my head around what needs to be done,

I have attached 3 files, one is the BUGutil file, which I think is used to 'load in' new python files, the others are 2 fury road python files, to show you something of what I want to add in.

I am not sure whether I need to load in these whole files, or take the code and merge it into an existing file. Kmod has so many python files I would not know which one it is though.

Any help getting my head around this problem is much appreciated thank you!
 

Attachments

you need to initialize the additional python you are calling in init.xml (..assets\config\ folder)

need a line like this:
<load mod="Yourmodname"/>

then...
make a Yourmodname.xml in the same folder (assets\config)

Like this...

Yourmodname.xml
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<mod id="Yourmodname" 
	 name="Yourmodname"
	 author="You" 
	 version="2.00" 
	 date="16 Aug 10" 
	 url="http://forums.civfanatics.com/showthread.php?t=477607">

	<events module="CvFuryRoadEvents" />
	<gameutils module="CvFuryRoadGameUtils " class="CvFuryRoadGameUtils"/>
</mod>

That will load the gameutils.
 
They should complement each other. I'm not sure how it would work if you directly wrote conflicting statements like two if you have building X = then do Y in two different files.

Consider if you have two different python files with onbuildingbuilts..
pythonfileA.py and pythonfileB.py and both modify the onbuildingbuilt function.

If one has a statement when a castle is built do X and the other if a barracks is built do Y and both python files are loaded, then both situations will run.

If you have two files that modify barracks when they are built then you should really combine the effects and clean up your code.

You follow me there, sorry for being somewhat abstract. Does that answer your question?
 
Yes thanks that is great :-)Hopefully I won't hit the conflicts issue.

I will have to play a bit and see if anything like that happens, but it shouldn't as K-mod is mostly about AI changes and interface changes rather than 'game rule' changes (for the most part) So finger crossed it will be fine.

If not i will just come begging for more help as ever ;-P

Thanks again :)
 
those look fine. Do you have those files in your python directory? Since that looks right I'd guess your mod can't find the CvFuryRoadEvents and CvFuryRoadGameUtils

If they are there, go ahead an post your init.xml and your mod's xml initialization file

edit: just to clarify, it's never worked right? Or was it working but now not?
 
no it never worked I was just sow to getting around to fixing it as it wasn't game breaking :)

Ok i THINK these are the files, let me know if you need to see something else. Oh and the 2 Fury files are 'loose' in the main python folder. At first i thought it might be because something in the python files was referring to something that was not referenced, but I think I have eliminated that possibility so confusion once again reigns.

:D
 

Attachments

That should be fine. The spelling of the fury road file is accurate right? Next I guess could you post them here?

I did check you init.xml and moved your mod's thing to after all the BUG stuff. See if it makes a difference.
 

Attachments

no that didn't make a difference....

I will double check the spelling of the files, but I think it is right.

At the moment most of the stuff in the python files i have commented out, as i am trying to reintroduce it piece by piece as a lot of the stuff it refers to does not exist in my version.

I don't know what kind of affect this would have on the files though. Right now I am not sure if i have removed enough or not, the thing I am mostly trying to keep hold of is the Fury Road method of founding a religion by a building, and not by a tech. The other thing that I think is left in is something about animal spawning.
 

Attachments

I'm not sure at this point. Can you post your logs directory? (You have logging enabled right?)

Load up a a game and quit after you get the error messages and post them here. My mod has a CvEventManager but I have all the functions in there even if they do their vannila actions. That's the main one I work off of. But I think your way should work as I also have an addtional event manager CvGreatPersonModEventManager that only has a few functions. Can you also post the original furyroad python files that you are basing this off of?
 
Here you are, I attached all the Fury Road Python Files, just incase something else is needed from them.

I attached the entire logs folder also, if what you need isn't there then the python logs have been disabled again and i will have to remember how to switch it on again.

Thans for your help :)
 

Attachments

Check / Redo your indentation on line 32 in your CvFuryRoadEvents file. Also it says it can't find 'CvFuryRoadGameUtils, that might clear up though if you get the first file working

from PythonErr.log
Code:
..
IndentationError: unindent does not match any outer indentation level (CvFuryRoadEvents, line 32)
...
..
.
ConfigError: No such module 'CvFuryRoadGameUtils '
 
When I look at the logs, I usually only look at PythonErr.log and it tells me where to look. Sometimes it has line numbers sometimes it just mentions files. In the log you posted only fury rd gameutils is mentioned so I think your events module is error free at the moment ( whether it does all you wanted is another story).

So I took a look at the gameutils and compared it to mine. I compared it to my mods and noticed the main init statement was different. So I cleaned it up and removed all the self.init stuff, loaded it in my mod and got no python errors when I loaded it (pthonerr.log is blank while the game is loaded and no messages in game).

Here's the file as modified. Try this one and cross your fingers again.
 

Attachments

ok...embarassingly I thin I may have found what the problem was all along... there was a space inside the "CvFuryRoadgameUtils " quotes... and I thin that was what was breaking everything :D I got rid of it and i get no parsing erors now :D

Whether the python code actually works is an entirely different matter :D but we are at least moving in the right direction :) Thanyou for all your help so far, I really do appreciate it as I would be completely stuc without it!

I think we've cracked it! the religions did not randomly found on the 6 turn as they have been, so I thin the python is disabling their tech trigger! :D

Now I just have to see if when I implement the building trigger feature, if that wors too :)
 
Glad it's working! Success is good! Python is very picky especially about indentation and it gives you strange errors that don't seem to explain much at first. If you aren't using something equivalent I recommend notepad++ to edit python and winmerge to compare files. Again, glad this is working
 
Back
Top Bottom