Announcement

Collapse
No announcement yet.

[Python] Fully Extended CvCustomEventManager

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Python] Fully Extended CvCustomEventManager

    Fully Extended CvCustomEventManager v1
    By Impaler, based on the original by dsplaisted

    Inspired by dsplaisted's fine idea from this thread:

    I have extended it to cover all events, creating an ideal blank slate for Mod makers.

    All the Onevent functions of the normal Event Manager have been wraped, Mods calls can be inserted before or after any event is handled. If absolutly nessary The normal call can be skiped entirely, but this should be done only if a MOD needs to interupt the normal sequence of events that execute in the call to the parent. The replacment call will need to replicate all the funtion of the original. Any such MODs will ofcorse be incompatable with each other so try to stick to plain old insertion.

    This will serve as a template for Mod makers to use and Mod users to mix various Mods without knowing any real Python. Most mods should require only a single import, a single call and possibly a define.

    Place the Python folder in CustomAssets and then add any additional Python files needed for the Mod (XML merging is a whole different story). Place calls for the Mod under the Event that the Mod maker specifies. If you are good with Python this can be deduced even if the Mod maker hasn't been very clear about it. You can Comment out imports and calls to deactivate the Mod rather then remove the file (this also makes it easy to reactivate). If an update for the mod is made you can usualy just overwrite the old Python file to update.

    Mod makers should focus on making their Mods as modular and plugable as possible, encoding all the mods
    logic in a seperate file/s that gets imported and called rathern then inserting code (even if it is in nice coment blocks) into the EventManager. This will make it nearly impossible to accidently define a function twice, mix up their order or misspell them durring merging.

    It is my hope that Moders will begin to use this template for easier plugability, it can also serve as a tool to make Moding easier, in subsequent versions I would like to greatly expand the commenting on each event to the level of helpfull documentation and tips about when/how each event operates. Anyone who has above average insight on this should feel free to post the next version, well just keep adding untill its fully documented.
    Last edited by Impaler[WrG]; December 22, 2005, 13:02.
    Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest. - Thus spoke Zarathustra, Fredrick Nietzsche

  • #2
    You have "OnBeginGameTurn" listed twice:

    Code:
    def onGameEnd(self, argsList):
    		'Called at the End of the game'
    		self.parent.onGameEnd(self, argsList);
    		#INSERT MODS		
            def onBeginGameTurn(self, argsList):
    		'Called at the beginning of the end of each turn'
    		self.parent.onBeginGameTurn(self, argsList);
    		#INSERT MODS
    def onBeginGameTurn(self, argsList):
    		'Called at the beginning of the end of each turn'
    		self.parent.onBeginGameTurn(self, argsList);
    		#INSERT MODS
    Does the fact that it is indented make a difference? Does indenting serve the sme function in Python as {} do in other languages? It still kind of freaks me out not to see lots of {} telling me when a function or loop begins and ends.

    Roger Bacon

    Comment


    • #3
      Typo sorry, odd it dosn't cause an error, I will cut that exta def out. I dont see ware this indenting is coming from, I checked and my version dosn't have it indented, just duplicated.

      Indenting is critical in Python as it is used to indicate bracketing the way {} would in C (yes I agree it feels weird like the code is naked or something )
      Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest. - Thus spoke Zarathustra, Fredrick Nietzsche

      Comment


      • #4
        Updated version with duplication removed
        Attached Files
        Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest. - Thus spoke Zarathustra, Fredrick Nietzsche

        Comment


        • #5
          There is a typo on line 242. You have "slef.parent..." instead of "self.parent..." Strangely it didn't give me an error until pretty far into the game.

          Roger Bacon

          Comment


          • #6
            Typo Corrected
            Attached Files
            Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest. - Thus spoke Zarathustra, Fredrick Nietzsche

            Comment

            Working...
            X