[Python] Adapting MPME to BTS

Aquitaine

Chieftain
Joined
May 19, 2010
Messages
10
Hi there,

I've never modded Civ4 and am not too handy with Python, but I thought I'd try to update an old mod rather than just complain until someone else did and am hoping someone here can lend a hand.

I grabbed an old mod for vanilla Civ4 that was written in '05 and updated in '06 this morning. The point is to allow you to choose whether you want tech splash screens and wonder movies to play in MP. Most people obviously don't, but I'm playing with a couple people new to Civ4 and want the option of allowing them to play so that they can both appreciate the screens & movies and so they know to stop and ask what something means when it happens, rather then just 'so and so has researched such and such.'

This is the old mod:

http://forums.civfanatics.com/showthread.php?t=146969

I attempted to add in the relevant sections from the mod files to the new BTS files. It didn't work as I'm now getting errors about CvEventManager unable to load. I've attached my current 'version' of the mod, which is the BTS files with MPME changes (usually marked, though not always).

I'm hopeful that I'm just missing a couple things here and there. The relevant sections of the BTS files were not all that different from the stock civ4 files, but they were different enough! I'd also say that I don't care about the other stuff the mod does (FPS indicators, alarm clock) - I only care about movies, tech splash screens, and the religion-founding movies and dawn of man would be nice too.

Is anyone willing to lend a hand? I can't help but think that anyone familiar with Civ4 modding (i.e. not me) and Python could probably figure this out in a minute or two.

I put the files in my Steam/Civ 4 beyond the sword/Beyond the sword/assets/python folder as that seemed to be where BTS-specific stuff wants to be.

Thanks so much!
Aq
 

Attachments

Here's the Python error log, also:

Traceback (most recent call last):
ERR: Call function onEvent failed. Can't find module CvEventInterface
File "<string>", line 1, in ?
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
File "<string>", line 52, in load_module
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
File "CvEventInterface", line 13, in ?
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
File "<string>", line 35, in load_module
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
File "<string>", line 13, in _get_code
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
File "
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
CvEventManager
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
", line
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
314
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface

ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface

ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
global fps
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface

ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
^
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
SyntaxError
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
:
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
invalid syntax
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface

ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
Failed to load python module CvEventInterface.
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
Traceback (most recent call last):

File "<string>", line 1, in ?

File "<string>", line 52, in load_module

File "CvScreensInterface", line 3, in ?

File "<string>", line 35, in load_module

File "<string>", line 13, in _get_code

File "CvMainInterface", line 649

if (WriteReadOptions.readsettings(4)):

^

SyntaxError: invalid syntax
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
Failed to load python module CvScreensInterface.
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function showIntroMovie failed. Can't find module CvScreensInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
 
The python error log tells you that you have a syntax error in CvEventManager, line 314.
Code:
	def onUpdate(self, argsList):
		'Called every frame'
		fDeltaTime = argsList[0]
				   [COLOR="Red"]global fps[/COLOR]
					fps += 1
		
		# allow camera to be updated
		CvCameraControls.g_CameraControls.onUpdate( fDeltaTime )
That line on red is one space further left than it should be, also don't use spaces instead of tabs, otherwise you'll have some nasty errors like this. So replace those three spaces with one tab and the error should be fixed. :)
 
I cleaned out the spaces but still no luck - same error on 314 (though thanks for showing me where to look for the error!)

I read that it's bad to mix spaces and lines (the original code did!), but just out of curiosity, why is the indentation important for anything other than cleanliness?
 
I cleaned out the spaces but still no luck - same error on 314 (though thanks for showing me where to look for the error!)

I read that it's bad to mix spaces and lines (the original code did!), but just out of curiosity, why is the indentation important for anything other than cleanliness?

Could you show what you did? It might be easier to find the error.

I think it's just part of python, although I have no idea. :)
 
I poked around a bit and discovered that Python is indeed very particular about indentation. That's pretty neat - never run into that before quite so explicitly. It might be a PITA for me right now but I kind of like it!

CvEventManager had several indentation errors but the 314 error (and a later one) are 'syntax errors.' I really don't care about the FPS stuff so I just commented out 314 but am now having an issue on line 545, also a syntax error, for what looks like a plain jane if statement.

Had to re-upload the whole RAR as it doesn't like just a .py file.

Thanks for your help!
 

Attachments

Ah, no, that's an indentation error too...figgered it out right after I uploaded it. Will work a bit more and post progress.
 
Python uses indentation instead of braces { and } to group related statements unlike Java, C, C++, C#, PHP, etc. If you have an editor that auto-indents like Notepad++, it can be easier for new coders to work with.
 
Back
Top Bottom