Kick units out

Settler Religions doesn't, I just checked it out, all you need to do is, in your custom event manager:

Code:
import SettlerReligion
sr = SettlerReligion.SettlerReligion()

Then, add the red lines to the correct places:
Code:
	def onUnitBuilt(self, argsList):
		self.parent.onUnitBuilt(self, argsList)
		[COLOR="red"]sr.onUnitBuilt(argsList)[/COLOR]

	def onUnitLost(self, argsList):
		self.parent.onUnitLost(self, argsList)
		[COLOR="red"]sr.onUnitLost(argsList)[/COLOR]

	def onCityBuilt(self, argsList):
		self.parent.onCityBuilt(self, argsList)
		[COLOR="Red"]sr.onCityBuilt(argsList)[/COLOR]

Edit, just warning you, this SHOULD work, but I've not tested it, whereas I have tested the Civ4lerts stuff, as I had some difficulty getting different modular python systems to work together :p

yeah the settlers thing really threw me off, i tried for about 2 hours trying to get it to work, and theres actually 2 mod comps for it to and i couldnt get either to work :mad:, nonetheless ill try both tonite and tell you how it goes, apreciate the help :D

Edit: Sweet that was my 300th post, im a prince :D were my crown?
 
I looked at the one you linked to, you can just ignore the EventManager file included, just copy the SettlerReligion file and then add the lines I showed and it should work :)
 
Did you enable Python exceptions yet? You need to do this, because you're messing up your code every time you try to edit the modules.

Also make sure to use UTF-8 text encoding when you save your edits.

So, in other words; Its not the code. The code seems to be pretty straight forwards. Its you who is messing things up. You should probably just hand this job over to someone who's done this before. Right now you're just wasting everybody's time, your own mostly.
 
And, make sure you're using either indents or spaces, not a mixture.
I prefer indents, and what I had to do with that file was copy an indent character, then go Replace All in my editor, place four spaces in my Find box, paste the indent character into the Replace With box, then go Replace All.
Not sure how you'd do that in most editors, I use Notepad++, just make sure you're not getting them mixed up.
 
And, make sure you're using either indents or spaces, not a mixture.
I prefer indents, and what I had to do with that file was copy an indent character, then go Replace All in my editor, place four spaces in my Find box, paste the indent character into the Replace With box, then go Replace All.
Not sure how you'd do that in most editors, I use Notepad++, just make sure you're not getting them mixed up.

Yeah i use notepad++ too, i have no idea where i would be without it:crazyeye: im gonna put my python file from my mod up here, if you could help me that would be great:D not sure what files you exactly need, so decided to put up the whole folder since its like only 100 kb (yeah i dont do alot of python) Thanks for the help, i really apreciate it!

Did you enable Python exceptions yet? You need to do this, because you're messing up your code every time you try to edit the modules.

Also make sure to use UTF-8 text encoding when you save your edits.

So, in other words; Its not the code. The code seems to be pretty straight forwards. Its you who is messing things up. You should probably just hand this job over to someone who's done this before. Right now you're just wasting everybody's time, your own mostly.

No reason to be to harsh;) ive never ever dont python before and your a python master, so cut me a little slack. Not really wasting any1s time, if i never try ill never learn how to do python
 

Attachments

Right, I can't see how you got it to work at all, you didn't have the Civ4lerts or the SettlerReligion files, and I think you need CvEventInterface for the custom event manager to work, so I included that too.

The only file I actually changed was the custom event manager file, and I commented what I changed with #Jemonn :D

You might get some errors with the included Civ4lerts file, as I changed my copy to add in some features, and I'm not sure whether I removed them all properly, but I'm sure I did.

Now, go to your Beyond The Sword folder in Program Files, double-click on _Civ4Config shortcut, and then:
Code:
; Set to 1 for no python exception popups
HidePythonExceptions = [COLOR="Red"]1[/COLOR]
Change the 1 to a 0.

Then:
Code:
; Enable the logging system
LoggingEnabled = 1

; Enable synchronization logging
SynchLog = 1

; Overwrite old network and message logs
OverwriteLogs = 1

; Enable rand event logging
RandLog = 1

; Enable message logging
MessageLog = 1

Make sure they're all set to 1.
I'm not too sure what ones control what, all I know is that, with all them set, you can get debug logs for Python.

Now, when your Python breaks, ingame, you'll get a popup telling you the filename and the line that's causing issues.
 

Attachments

Right, I can't see how you got it to work at all, you didn't have the Civ4lerts or the SettlerReligion files, and I think you need CvEventInterface for the custom event manager to work, so I included that too.

The only file I actually changed was the custom event manager file, and I commented what I changed with #Jemonn :D

You might get some errors with the included Civ4lerts file, as I changed my copy to add in some features, and I'm not sure whether I removed them all properly, but I'm sure I did.

Now, go to your Beyond The Sword folder in Program Files, double-click on _Civ4Config shortcut, and then:
Code:
; Set to 1 for no python exception popups
HidePythonExceptions = [COLOR="Red"]1[/COLOR]
Change the 1 to a 0.

Then:
Code:
; Enable the logging system
LoggingEnabled = 1

; Enable synchronization logging
SynchLog = 1

; Overwrite old network and message logs
OverwriteLogs = 1

; Enable rand event logging
RandLog = 1

; Enable message logging
MessageLog = 1

Make sure they're all set to 1.
I'm not too sure what ones control what, all I know is that, with all them set, you can get debug logs for Python.

Now, when your Python breaks, ingame, you'll get a popup telling you the filename and the line that's causing issues.



Thanks and yeah sorry i took those files out, that was the clean copy of the python, ill put the files back in :D thanks for the help really appreciate it, if it works ill give you credit in my mod :D
 
Got a bunch of errors:
File "<sting>", line 1, in?
File "<sting>", line 52 in load_module
File "CvEventInterface", line 13, in?
File "<sting>", line 35, in load_module
File "<sting>", line13 in_get_code
File "
CvCustomEventManager
", line
371
(two blank error messages)
def addeventHandler(self, eventtype, evenhandler):
Then about 60 some blank more error message, didnt feel like countin:lol:

Then about 5 more erros
 
Then just overwrite the files I included :)

And, I remember how hard Python was at first, I was always breaking stuff, but I learned how to mod through trial, error, and asking lots of questions, so, I'll be happy to answer any questions you might have, as I've written some really complex Python, like a script that uses a base number, adds a random number, then checks for civs that are in a set of lists, then rolls another couple of random numbers, and then finally gives them a certain religion in their capital. It may sound simple, but it's almost 200 lines of Python, then I've got some scripts that scan the whole map, check around each Mana node that's on the map, check all terrain, features, improvements, water, peaks, hills, and then decides what mana node type would be most appropriate to place there, once again, sounds simple, almost 400 lines, and neither of these scripts really affects gameplay.

Then, in a mod I play, Rise From Erebus, we had barb troubles, the AI weren't expanding, or building workers, so I made a set of scripts, ~200 lines in total, most of them being comments or other features to let me tweak them easily, that gives the AI a free warrior, or warrior UU on founding their first city, a free worker on founding their 1st, 3rd, 5th cities, and free settlers on certain turns.

These may sound like simple changes, but they changed the game from one where around 4-5 AIs were dying before turn 100, to a game where you have to expand quickly to stay competitive.

Python's a powerful tool, it's well worth learning :)
 
That's not too much help, run it again, keep clicking okay or whatever, until you get to the main menu, then go BtS, _Civ4Logs, look in either PythonDebug, or a PythonError log, and see whether it helps.

That line really hasn't changed, not sure why it's causing errors..
 
That's not too much help, run it again, keep clicking okay or whatever, until you get to the main menu, then go BtS, _Civ4Logs, look in either PythonDebug, or a PythonError log, and see whether it helps.

That line really hasn't changed, not sure why it's causing errors..

looks pretty much the same

PHP:
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
CvCustomEventManager
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
371
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
def addEventHandler(self, eventType, eventHandler):
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
IndentationError
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
unindent does not match any outer indentation level
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
ERR: Call function onEvent failed. Can't find module CvEventInterface
 
Right, did you copy the CvEventInterface file across into your EntryPoints folder?
 
And if you remove the file, you still get errors?

EDIT: Do any of the other Python logs have anything in at all? Paste them here :)
 
If you remove the lines that say "ERR: Call function onEvent failed. Can't find module CvEventInterface" you can see the real error message.

The actual error is "unindent does not match any outer indentation level". So your indentation is messed up. Where? On (or very close to) line 371 in CvCustomEventManager.
 
If you remove the lines that say "ERR: Call function onEvent failed. Can't find module CvEventInterface" you can see the real error message.

The actual error is "unindent does not match any outer indentation level". So your indentation is messed up. Where? On (or very close to) line 371 in CvCustomEventManager.

Oh yeah :p I wonder why the errors did that.
Anyway, yes, he's correct.

Go to line 371, select that line, and everything below it, to the end of the file, and then unindent it all one level. (Shift+Tab)
 
Oh yeah :p I wonder why the errors did that.
Anyway, yes, he's correct.

Go to line 371, select that line, and everything below it, to the end of the file, and then unindent it all one level. (Shift+Tab)

hmm well it worked, somwhat, when i loaded the mod i no longer got errors:D but when i loaded the mod i got a popup saying i had errors, heres a screenshot
 

Attachments

  • Civ4ScreenShot0023.JPG
    Civ4ScreenShot0023.JPG
    119.6 KB · Views: 69
Go to that line in your file, and make the red changes:

Code:
	def onCityBuilt(self, argsList):
		'City Built'
		pCity = argsList[0]
		if ([COLOR="Red"]pCity[/COLOR].getOwner() == gc.getGame().getActivePlayer()):
			self.__eventEditCityNameBegin([COLOR="red"]pCity[/COLOR], False)	
		CvUtil.pyPrint('City Built Event: %s' %([COLOR="red"]pCity[/COLOR].getName()))
 
If you are still working on units no being removed on war, Fall From Heaven prevents this for on of the religions, through the sneakattack XML tag (I think)
 
Back
Top Bottom