Simple Python Things

So all I have to do is replace the part 3 in my python with this python?

You just have to add the part between self.oldcity = [iPlayer,iCity] and break.
But replacing should also do it.

And then write up text for it?

And that would be TXT_KEY_NEWTEXT right? Which announces where they will be held to every player?

Right :yup::
 
Woah, mods a plenty! :D

I think some-a this will go to my mod.
 
Hello, The J!

I finally got some time today to test out WoL with python exceptions. Since this is the first time I did this, if there's something I missed, don't hesitate to tell me. :)

Anyhow, no python exception pop-up screen came up after a battle, so I don't know if that would prove useless to you, then. However, a python exception pop-up screen did pop up when I founded my first city. I'm not sure what it means, however.

I've attached a picture, or you can see it right below:

attachment.php




Thanks again so much for all your help!
 

Attachments

  • First Exception.JPG
    First Exception.JPG
    53.8 KB · Views: 312
Thanks a lot The_J, you're the man. :goodjob:

:)

Woah, mods a plenty! :D

I think some-a this will go to my mod.

I hope so :D.

Any luck yet on that Espionage problem yet?

Yes ;).

I'll upload my fixed sneak promotion in the next minutes.
For the modders, who have the promotion in their mod: In the code, there's 6 times myteam.setEspionagePointsAgainstTeam mentioned. Change it to myteam.changeEspionagePointsAgainstTeam , that will fix it.




Anyhow, no python exception pop-up screen came up after a battle, so I don't know if that would prove useless to you, then.

Honestly, i'm not sure, what it means. I'm a bit confused.
Is the bug in the current downloadable version of WoL, or does it work there?


However, a python exception pop-up screen did pop up when I founded my first city. I'm not sure what it means, however.

I've attached a picture, or you can see it right below:

Did you add tsentom's sphinx wonder? It seems, that's a typo in the building you've assigned it to. Check if BUILDING_SPHINX (or whatever you have there) is written correctly.
 
Honestly, i'm not sure, what it means. I'm a bit confused.
Is the bug in the current downloadable version of WoL, or does it work there?

The bug is in the current downloadable version, though oddly enough no one has reported it.


Did you add tsentom's sphinx wonder? It seems, that's a typo in the building you've assigned it to. Check if BUILDING_SPHINX (or whatever you have there) is written correctly.

Alright, thanks for pointing that out.

I owe you a big one on this. :)
 
Any luck yet on that Espionage problem yet?


Can i get the code then, its really stating to bug me, it appears almost all the time now.


Traceback (most recent call last):
File "BugEventManager", line 350, in _handleDefaultEvent
File "Espionage", line 109, in onCombatResult
RuntimeError: unidentifiable C++ exception
 
Ops, sorry, i thought you've been talking about the older problem.

well, for this problem...uhm...change:
PHP:
if pWinner.isHasPromotion(gc.getInfoTypeForString('PROMOTION_INDUSTRYESPIONAGE')):

to:
PHP:
if pWinner.isHasPromotion(gc.getInfoTypeForString('PROMOTION_INDUSTRYESPIONAGE')) and gc.getTeam(gc.getPlayer(pLoser.getOwner()).getTeam()).getCurrentResearch>=0:
 
Ops, sorry, i thought you've been talking about the older problem.

well, for this problem...uhm...change:
PHP:
if pWinner.isHasPromotion(gc.getInfoTypeForString('PROMOTION_INDUSTRYESPIONAGE')):

to:
PHP:
if pWinner.isHasPromotion(gc.getInfoTypeForString('PROMOTION_INDUSTRYESPIONAGE')) and gc.getTeam(gc.getPlayer(pLoser.getOwner()).getTeam()).getCurrentResearch>=0:

OK tried that, got this now:

Traceback (most recent call last):
File "BugEventManager", line 350, in _handleDefaultEvent
File "Espionage", line 85, in onCombatResult
AttributeError: 'CyTeam' object has no attribute 'getCurrentResearch'
 
Shouldn't it be something like this?
Code:
if pWinner.isHasPromotion(gc.getInfoTypeForString('PROMOTION_INDUSTRYESPIONAGE')) and [COLOR="Blue"]gc.getPlayer(pLoser.getOwner()).getCurrentResearch()[/COLOR]>=0:
 
No, the research is tied to the team, not to the player (or i remember it wrong), but before the >=0: a pair of brackets () is missing.
Sorry for that.

It's possible to have different researches in one team but each player can have only one current research at a time. So I don't think it would be wise to tie current research to a team.
See the attachment. ;)
 
OK it got rid of the error messages always showing up, BUT now the indicator that it plundered beakers does not always show up when i have defeated an opponent?

So i really dont know if it is working correctly or not?:crazyeye: Sometimes it does sometimes it doesnt.

EDIT: Thx
 
No, that's correct. If the enemy does not research anything, you will not get a beaker.
I think, i should change it, so that you then also get 1 beaker...okay, when i have the time, i'll do that.

OK thx, but i cannot get this to work correctly in the MLF, i know i have the XML stuff correct. Or do you need the whole folder? If so, here is where i have them: http://forums.civfanatics.com/showthread.php?t=346030

Spoiler :
Code:
from CvPythonExtensions import *
import CvEventInterface
import CvUtil
import BugUtil
import PyHelpers

gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo
PyCity = PyHelpers.PyCity
PyGame = PyHelpers.PyGame

class Militia:
	def __init__(self, eventManager):
	
		eventManager.addEventHandler("ImprovementBuilt", self.onImprovementBuilt)

	def onImprovementBuilt(self, argsList):
		'Improvement Built'
		iImprovement, iX, iY = argsList
###Militia Start ###
		pPlot = CyMap().plot(iX, iY)
		if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_FARM'):
                        charity = gc.getInfoTypeForString( "CIVIC_CHARITY" )
                        iPlayer = pPlot.getOwner()
                        pPlayer = gc.getPlayer(iPlayer)
                        if (pPlayer.isCivic(charity)==True):
                                era = pPlayer.getCurrentEra ()
                                if (era == gc.getInfoTypeForString( "ERA_MEDIEVAL" )):
                                        militia = gc.getInfoTypeForString( 'UNIT_MILITIA_MEDIEVAL' )
                                        pNewUnit = pPlayer.initUnit( militia, iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
                                elif (era == gc.getInfoTypeForString( "ERA_RENAISSANCE" )):
                                        militia = gc.getInfoTypeForString( 'UNIT_MILITIA_RENAISSANCE' )
                                        pNewUnit = pPlayer.initUnit( militia, iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
                                elif (era == gc.getInfoTypeForString( "ERA_INDUSTRIAL" )):
                                        militia = gc.getInfoTypeForString( 'UNIT_MILITIA_INDUSTRIAL' )
                                        pNewUnit = pPlayer.initUnit( militia, iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
                                elif (era == gc.getInfoTypeForString( "ERA_MODERN" )):
                                        militia = gc.getInfoTypeForString( 'UNIT_MILITIA_MODERN' )
                                        pNewUnit = pPlayer.initUnit( militia, iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
                                CyInterface().addMessage(iPlayer,False,15,CyTranslator().getText("TXT_RECRUITED",()),'',0,'Art/Interface/Buttons/Civics/Serfdom.dds',ColorTypes(44), iX, iY, True,True)
###Militia End###
 
OK thx, but i cannot get this to work correctly in the MLF, i know i have the XML stuff correct. Or do you need the whole folder? If so, here is where i have them:

What's not working?
Does it just not do anything?
Or partially?
 
hmm...the exceptions are turned on, right?
RoM is the biggest modpack around, and i know, that Zappara has min. added 1 era. Did he maybe also change the old eras?

Only for testing: Could you maybe add the line CyInterface().addMessage(etc..., which is at the end of the code, directly after iImprovement, iX, iY = argsList in the next line?
Then build an improvement, and look, if it throws an exception (with this change, it should throw one; only for testing). I just want to see, if the whole thing at all works.
 
Back
Top Bottom