Modular Python Troubles

Ominous Destiny

Chieftain
Joined
Sep 10, 2013
Messages
42
I'm trying to add a very basic modular event which has a Python Callback. However, my .py is causing some type of issue... when it's included under my folder, it causes ALL the modular python files to not load correctly :confused:

Has anyone else had a similar issue?
 
Short answer is yes.

I'm not sure of the exact cause.

Try disabling any non-essential modules you have.
Make sure your python file is named the way the modular loading system expects it to be named.
Try it with a totally basic python, e.g. Only a spell python pre requisite where the python definition is
Code:
        return True
 
The issue is very perplexing. I removed all the modules except my own. The result was the same. So I am certain that it's my module. The XML appears to be working fine, events appear as expected with the correct strings. And the python appears to be loading fine because if I make changes to the module's python, CIV will reload the python files.

I'll keep troubleshooting I guess. There has to be a very particular reason why some modules work and others do not.

[Edit]

Found the solution... a single bad def in a modular file will cause the entire modular .py (so in this case, all event.py files) to not work properly. I eventually got the spell python to work, so I figured I'd do a similar experiment with a pyhelp in the event file. I created just a basic event which displayed a text string with the mouse over. This worked, so I slowly added back def until I it hit the one that was causing the issue.

If you can confirm this with one of your modules which isn't working, we might be able to put this issue to rest?

[Edit 2]

Specifically, I had a TAB TAB SPACE (instead of a TAB TAB) somewhere in my code, which caused the entire modular event.py for every module to fail.

So bottom line is: operator error :lol:
 
Good to know you're sorted.
I tend to build up my python very slowly with loads of checks to make sure that the code in each branch can be navigated. Sometimes I also restart a python file as you did to track down my errors.

TAB TAB SPACE should get caught by using "Check Module" in the editer.
 
Top Bottom