[BtS] JKP1187's EVENTS

This is strange. It seems any python mod that uses CvCustomEventManager.py will cause your events to misfire. I'm getting things like the pirates event popping up all the way back in 3300 BC. The strangest thing is that even several turns later, there are never any pirates anywhere on the map (I've checked by going into worldbuilder). So it seems the dialog for the event is popping up, but the event itself is not taking place.
BTW, can you think of any reason that one line in CvEventManager would prevent pop-up windows from appearing?
 
Yes. If I don't merge it with those things, it works fine. This is very strange, since when I "merge" them with wonders like the Flavian Amphitheater or Machu Picchu, I don't have to edit anything besides the CvCustomEventManager.py file, save for the CvGameUtil.py that Petra and Machu Picchu edit. I know that the problem isn't with Machu Picchu because I've tried it without Picchu or Petra and I still get the bug. Like I said, it doesn't seem to be actually doing anything besides giving event messages when the event that is being talked about isn't actually firing.
For instance, I have received the event where you can provide aid to a brother of the faith without actually going to war along with them. However, because there was no war going on, I could only choose the first option (do nothing). I've had the pirate event pop up for me a few times, and each time there are no actual pirates spawned because the requirements for the event (certain number of ships on the map) have not been met.
 
Gosh, I don't know what to tell you here.

I just did a merge of the NextWar mod (which includes the Events mod) and jdog's Revolution mod -- which also includes the CvCustomEventManager.py file, and in my initial testing, everything worked fine. Revolution worked the way it was supposed to (I had some revolting cities and whatnot,) as did the events. Two pirate events occurred in the first test run, and they fired according to the prerequisites (and pirate ships appeared.)

I don't know what's going on in the other mod that you're working with, but I suspect that something might have gone wrong in the merge (like an incorrectly indented line -- Python is REALLY touchy about that,) or that there is some oddball code in the other mod(s) that you're merging.

What mods are you trying to merge, anyway?
 
I don't know what's going on in the other mod that you're working with, but I suspect that something might have gone wrong in the merge (like an incorrectly indented line -- Python is REALLY touchy about that,) or that there is some oddball code in the other mod(s) that you're merging.
Incorrect indentation? You mean like tabs? That can screw it up?
BTW, what program do you use for merging?
 
Incorrect indentation? You mean like tabs? That can screw it up?
BTW, what program do you use for merging?

Yes, oh my, yes, it sure can -- Python is absolutely tab-sensitive. You might want to check out this Python tutorial if you are interested in Python modding:

http://sthurlow.com/python/

I usually use WinMerge for merging XMLs, C++, and Python, which can be found as a free download online.

You should also download Idle if you haven't already. It's a Python editor and allows you to check for Python-specific errors.
 
Arrrg! I thought I left that crap when I stopped modding CnC Generals. Honestly, you'd think they would have figured out how to get programs to ignore tabs.
But your mode file (CvRandomEventInterface.py) has lots of tabs in it, or do preceeding tabs not count?

Seriously -- look at the tutorial. All indents count in Python. (I think Lesson #4 discusses indentations).

And yes, Humanity has achieved a programming language that doesn't care about indents. It's called: C++. :D
 
By the way, if you want to make sure that you did it right, test them out in game. Start up a new game, use world builder to give your civ the appropriate techs. Then fire up the Python console by hitting SHIFT+` (the "~" key. Make sure you hit SHIFT-- if you get a blank console with nothing on it, escape out of it and try again). enter the following:

Code:
num = gc.getInfoTypeForString("EVENTTRIGGER_X")
p=gc.getPlayer(0)
p.trigger(num)

(everything is case-sensitive). In place of "X" enter the name of the event as it is written in the trigger XML file (e.g., "EVENTTRIGGER_BLACKBEARD").

If it triggers properly, you're golden. If you get a python error, something went wrong and you'll need to debug.
 
I noticed a small bug in your Python code for the FUTBOL_WAR event:

On line 4053 in CvRandomInterface.py

Code:
if not gc.getTeam(otherPlayer.getTeam()).canChangeWarPeace(player.getTeam()):

should be:

Code:
if not gc.getTeam(otherPlayer.getTeam()).canChangeWarPeace(pPlayer.getTeam()):
 
Aaarrgghh! That must've been sitting like that for months....

I really need to go back and review the code for some of those events I scripted back in November, when I was just starting out, when my programming style resembled John Searle's Chinese Room Hypothesis ...

This is fixed and v. 1.18 is now uploaded.
 
I should have mentioned this earlier, because we already converted a version (I think 0.99) of your mod for the WoC-project and this python exception bug was assigned to me when it was reported by TAFireHawk (the project leader, he deserves credit for finding it). It was a quick fix and I forgot about it until today, when I got a notification on your new version.
 
Top Bottom