Exception while modding during gameplay

LuKo

The Royal Guard
Joined
Aug 28, 2006
Messages
1,533
Location
Poland
Hi! I'm trying to create scenario to RFC, using Baldyr's PyScenario (http://forums.civfanatics.com/showthread.php?t=366743). Though, when I change Python during gameplay i get this exception: http://img685.imageshack.us/img685/3664/civ4screenshot0009t.jpg blank, "tuple index out of range", "IndexError", "File "PyScenario", line 1930, in tuplePair", "File "PyScenario", line 127, in setTarget", "File "PyScenario", line 195, in target", "File "Scenario", line 6, in ?", "File "string", line 52, in load_module", "File "PyScenario", line 42, in setup", "File "PyScenario", line 48, in rebuild", "File "CvRFCEventHandler", line 867, in onKbdEvent", "File "CvEventManager", line 132, in _handleConsumableEvent", "File "CvEventManager", line 108, in handleEvent", "File "CvEventInterface", line 23, in onEvent", "Traceback (most recent call last):"
It doesn't matter what I do-even slightest change is followed by exception. When I restart the game everything is normal once again. I'm total modding noob and I can't figure what possibly I could have done wrong (despite Baldyr's help).
 
I have found the way that Civ4 reloads Python modules is not so useful. Working on the plane in flight is usually fraught with problems.
 
I agree with EF. In Dune Wars, it often happens that when I reload python, and then click in the tech tree, I get an exception from the tech picker. This is even vanilla code. Modifying on the fly is a highly useful idea, and in my case I can do useful things without using the tech picker. But clearly not all code is written to withstand being reloaded.
 
I mostly don't have any problems working with Python while the game is running. Its actually very helpful when making scenarios, as you can test out different approaches. But it has happened that I can't reload a module at all, and then I need to reboot. Not regularly though.

LuKo's CyPythonMgr.debugMsg() exception is getting the better of me, however. I haven't seen that one before and it seems to happen whatever he changes... So the only thing he can do is restart the game every time? (What does it say about text encoding, by the way?)

"tuple index out of range", "IndexError", "File "PyScenario", line 1930, in tuplePair", "File "PyScenario", line 127, in setTarget", "File "PyScenario", line 195, in target", "File "Scenario", line 6, in ?", "File "string", line 52, in load_module", "File "PyScenario", line 42, in setup", "File "PyScenario", line 48, in rebuild", "File "CvRFCEventHandler", line 867, in onKbdEvent", "File "CvEventManager", line 132, in _handleConsumableEvent", "File "CvEventManager", line 108, in handleEvent", "File "CvEventInterface", line 23, in onEvent", "Traceback (most recent call last):"
This seems just to be an invalid argument causing everything to crash, probably unrelated to the problem discussed above. The target() method is covered in the PyScenario Trigger API and it can actually take both tuples (one or two) - or integer values (two or four - one or two pairs). But if you feed it some other combinations of arguments it won't work. Like three integer values or one tuple and and one integer value, or something else that doesn't compute.
Spoiler :
target( <arguments> )
Given a pair of integer values these numbers will correspond to the X and Y map coordinates respectively. But a single tuple argument containing two values is also valid, so you can use whatever option feels most comfortable.

The method can also be used for defining a rectangular map area. Then you'd have to supply two sets of coordinates - the first one is always the lower left tile and the second one is the upper right tile making up the rectangle. Then all the tiles within this area are added to the plot list.

Two sets of coordinates can either be entered as a pair of tuples - or as four separate integer values. So these are all valid examples of use:
Code:
target(34,56)
target((34,56))
target((33,55),(35,57))
target(33,55,35,57)
It could be noted however that the target() method isn't entirely necessary for defining single map tiles, as many other methods can take map coordinates as arguments. But its always a viable option if you feel more comfortable with using it.
If the above isn't working for you then you have actually found a bug. Please report it in the beta-testing thread and make sure to submit the actual script causing it.

For now, can you get your PyScenario script working if you restart the game? (No exceptions, at all?) Because that would be a step in the right direction. :king:
 
In Dune Wars, it often happens that when I reload python, and then click in the tech tree, I get an exception from the tech picker.
I actually only think I've encountered this when I either happen to have any Advisor/Civilopedia window open while reloading - or when there was an exception during reloading. So I try to avoid opening such windows while modding. Most of the time they are alright once I reload Python again.
 
For now, can you get your PyScenario script working if you restart the game? (No exceptions, at all?) Because that would be a step in the right direction.

I don't have mine working script (I get no exceptions but nothing happens). So probably it is correct but conditions are never met. Anyway when I paste your (Baldyr's) scenario, I get exception, restart game- everything is working. With the exception my eagerness to mod is significantly lower.
 
I don't have mine working script (I get no exceptions but nothing happens). So probably it is correct but conditions are never met. Anyway when I paste your (Baldyr's) scenario, I get exception, restart game- everything is working. With the exception my eagerness to mod is significantly lower.
But if you, for a moment, forget about modding during gameplay. Can you install a premade script, fire up the game - and it works without exceptions?
 
Just tested- I've won UHV as Egypt with Sahara scenario. No exceptions.
:goodjob: So maybe you think that the scenario could be tweaked, then? (Too easy?) Please submit a report on your experience in the Sahara scenario thread. (The scenario worked though? There was actual desertification all over the place, right?)

This also means that PyScenario is working on your system and that you probably could edit the Scenario module and have it work also. For now, don't try to do this while the game is running. Or restart once you have changed something, as a rule.

With the latest version you won't get any more exceptions while loading the Scenario.py file, by the way. It will only say (in the debug log) that no valid module was found. So be on the lookout for that! (If nothing ever happens then probably no Triggers were ever loaded.)
 
Until now I tested my works at loaded game (Roman spawn- turn 90). I made more triggers ("Some have to work") and I get the exception: http://img33.imageshack.us/img33/1497/civ4screenshot0010m.jpg (some of triggers worked, though). That reminds me that exceptions that I quoted weren't in one window- every "" (added by my) means a new window (and was one or two blank exceptions).
 
BTW, set up exception logging so you don't have to deal with all those popups. You'll save yourself a huge headache and can then copy-n-paste them (use [CODE]...[/CODE] tags for readability) here. Just follow the first two sections on that page.
 
Until now I tested my works at loaded game (Roman spawn- turn 90). I made more triggers ("Some have to work") and I get the exception: http://img33.imageshack.us/img33/1497/civ4screenshot0010m.jpg (some of triggers worked, though). That reminds me that exceptions that I quoted weren't in one window- every "" (added by my) means a new window (and was one or two blank exceptions).
You really need to post the script you are using. I can see from the exception what went wrong, but not how it happened - what setting caused the script to use a None value instead of the requested integer value. If it wasn't you who caused it, then you might actually have found a bug and in that case I really need to fix it!

So please show me your work. (You can post it to me privately if you want.)

Also, the other approach might actually be helpful since you're kinda struggling. Try to get one fairly basic Trigger to work first, then try another and build from there. Otherwise it will be very hard for you to know what worked and what didn't - and why. It makes it harder to help you, also.
 
Back
Top Bottom