[modular python]
templatemod : modularPythonDemo
[modular python]
nameofpythonfile : nameOfModule
ok, the ini isn't quite self explanatory. Can you confirm if my analysis is correct
This is the contents of the iniCode:[modular python] templatemod : modularPythonDemo
I see it as:
Code:[modular python] nameofpythonfile : nameOfModule
Is this right ?
reading through modulareventmanager.py
There's a hell of a lot of things I'm seeing here, where you've disabled an event for modular loading ebcause it's called often. I believe one is onCombatResult
Don't you think people might want to run some sort of python after a battle ?? It's a pretty common area to modify. Am I misunderstanding what this means ?
I'm noticing in general, that you seem to have rebuild cvEventManager entirely, into the fallfurtherevents.py
I see lots of things broken up into seperate functions and marked by the event they correspond to. Rather than, as it was before, a huge mass of if statements within a few specific events (there were pages and pages of code within onUnitBuilt.
This method looks neater and more logical. Does it impair flexibility at all? And how about performance? does it have a significant effect on performance in either direction ?
And is this method a supplement to, or replacement of, the old method? if we merged it, would all event code have to be done this way?
Not that I'm complaining, I think it's better.
For creating my own python for my module, should I copy the first 9 lines from templatemod.py, and then add my stuff below? The first 9 lines look important
import modularEventKeeper
event = modularEventKeeper.EventKeeper()
spell = modularEventKeeper.CumulatingDict()
randomEvent = modularEventKeeper.CumulatingDict()
from CvPythonExtensions import *
import CvUtil
import CvScreensInterface
import CvDebugTools
import CvWBPopups
import PyHelpers
import Popup as PyPopup
import CvCameraControls
import CvTopCivs
import sys
import CvWorldBuilderScreen
import CvAdvisorUtils
import CvTechChooser
import CvIntroMovieScreen
import CustomFunctions
import ScenarioFunctions
#FfH: Card Game: begin
import CvSomniumInterface
import CvCorporationScreen
#FfH: Card Game: end
#FfH: Added by Kael 10/15/2008 for OOS Logging
import OOSLogger
#FfH: End Add
# globals
cf = CustomFunctions.CustomFunctions()
gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo
sf = ScenarioFunctions.ScenarioFunctions()
#FfH: Card Game: begin
cs = CvCorporationScreen.cs
#FfH: Card Game: end
import CvPythonExtensions
gc = CvPythonExtensions.CyGlobalContext()
does the @event.UnitBuilt() basically allow us to do modular python for any event, inserting it there as appropriate ?
Oh, and another question, since I'm already drowning you in them.
Can I have modular functions that call other functions?
Specifically, I want to make a "change back to druid" effect, and call it both from the Change Back spell, and also from the pyPerTurn while polymorphed. Can I do this without having to duplicate that code in two places ?
It is much more flexible, and I don't really know how to make things modular without it.
There is a performance penalty, but only time will tell if it is significant.
On the other hand, using a hash table as the event system does, rather than a mass of if statements should be quicker. In other words, registering an event for having a library built should be quicker than looking at every building that is built to see if it is a library.
I'm a bit confused here. What exactly would be slower, then? Are we likely to see a net gain or loss in terms of performance, for various types of functions?
This also includes a somniumintterface.py
What exactly did you change in there? and why wouldn't changing that back also be necessary to uninstall ?
---------------------------
Python Exception
---------------------------
Traceback (most recent call last):
---------------------------
OK
---------------------------
---------------------------
Python Exception
---------------------------
File "<string>", line 1, in ?
---------------------------
OK
---------------------------
---------------------------
Python Exception
---------------------------
File "<string>", line 52, in load_module
---------------------------
OK
---------------------------
---------------------------
Python Exception
---------------------------
File "CvEventInterface", line 13, in ?
---------------------------
OK
---------------------------
---------------------------
Python Exception
---------------------------
File "<string>", line 52, in load_module
---------------------------
OK
---------------------------
---------------------------
Python Exception
---------------------------
File "ModularEventManager", line 1729, in ?
---------------------------
OK
---------------------------
---------------------------
Python Exception
---------------------------
ImportError
---------------------------
OK
---------------------------
---------------------------
Python Exception
---------------------------
:
---------------------------
OK
---------------------------
---------------------------
Python Exception
---------------------------
Cant find the install directory.
---------------------------
OK
---------------------------
---------------------------
Python Exception
---------------------------
---------------------------
OK
---------------------------
---------------------------
Python Exception
---------------------------
Failed to load python module CvEventInterface.
---------------------------
OK
---------------------------
I'll hazard a guess that it's not supposed to do that.
Traceback (most recent call last):
File "<string>", line 1, in ?
File "<string>", line 52, in load_module
File "CvEventInterface", line 13, in ?
File "<string>", line 52, in load_module
File "ModularEventManager", line 1729, in ?
ImportError
:
Cant find the install directory.
Failed to load python module CvEventInterface.