ModModder's Guide

Is it possible to create a modular event with modular python? (PythonCallback)
 
I've done it, but apparently its buggy. Worth a try, but keep in mind that the XML for events isn't perfect.
 
I've done it, but apparently its buggy. Worth a try, but keep in mind that the XML for events isn't perfect.

did u use a PythonCallback in your events?
i thought only SpellInterface, EventInterface, (GameUtils) and EventManager are supported...
for events i need CvRandomEventInterface.py because the PythonCallback refers to this file.
well, i'm pretty new to modding so maybe i didnt understand it right...
can some1 plz help?
 
I have (had) a modded version that supported more files, I don't any more.
Ask anw, he's the one that coded MPL, he can help more than I can :)
 
ahh, anw = arcticnightwolf ... :)

making new file to be modular isn't problem

did u mean no problem for you (the creator of this great "tool")
or no problems for modders so i can do it myself because i have no idea how to...

btw thx for everyone who is trying to help me
 
ahm, ...
and what now?
should i wait for the next patch or is it just impossible to make events (with py) modular?
 
it definetely is possible i think :D

i got a question: is it possible for me to view the python event callbacks?
 
Now I found this in another thread: ( http://forums.civfanatics.com/showpost.php?p=9037399&postcount=4 )

Spoiler :


How to Make Python true Modular

Python generally cannot be made modular. If you modify cvgameutils.py for example, a later patch would erase all your changes. However what you can do is to link to python via XML. To do this you need to use the import command.

<SpellInfo>
<Type>SPELL_MAKE_FUNNY_STUFF_WITH_PYTHON</Type>
<PyResult>__import__('funnystuff').spellSpiralGate(pCaster)</PyResult>
<PyRequirement>__import__('funnystuff').reqSpiralGate(pCaster)</PyRequirement>
</SpellInfo>



In this case the python code would be in the funnystuff.py file and everytime you apply a new Wildmana patch this file isn't touched, so your python changes persist.

Currently you can do this via spells and traits. For Spells, the requirement and result of a spell can be made modular. For traits the pythonPerTurn can be made modular.

Theoretically allmost all python could be made modular if there is a need for a modmod by adding SDK support for additional python callback via XML.

[...]



the part with the __import__('funnystuff') would be exactly what i need for the event PythonCallback:
<PythonCallback>__import__('funnystuff').doPyMyModEvent1</PythonCallback>
<PythonCanDo>__import__('funnystuff').candoPyMyModEvent1</PythonCanDo>
<PythonHelp>__import__('funnystuff').helpPyMyModEvent1</PythonHelp>

i tryed it but unfortunately its not working :(
is there some way to add this __improt__ thingy in RifE so it works with the CIV4EventInfos.xml ?
 
__import__ is a basic part of python. You need to place the funnystuff.py file somewhere CivIV looks for python modules.

That's Rise from Erebus\Assets\python.

However: Random events work differently from spells and the various other python callbacks FFH added. So this trick does not apply to random events.

Still it's easy making the random event file modular, so it should be possible soon anyway.
 
Now I found this in another thread: ( http://forums.civfanatics.com/showpost.php?p=9037399&postcount=4 )
the part with the __import__('funnystuff') would be exactly what i need for the event PythonCallback:
<PythonCallback>__import__('funnystuff').doPyMyModEvent1</PythonCallback>
<PythonCanDo>__import__('funnystuff').candoPyMyModEvent1</PythonCanDo>
<PythonHelp>__import__('funnystuff').helpPyMyModEvent1</PythonHelp>

i tryed it but unfortunately its not working :(
is there some way to add this __improt__ thingy in RifE so it works with the CIV4EventInfos.xml ?

i'm afraid that this would work, if the file "funnystuff" was in /Rise from Erebus/Assets/python/, so it wont work as modular i think
 
what do you mean with soon?

A team member must add the code to the mod and then the patch must be released.

I know from experience that it's easy, all but trivial, but someone has to make the change...
 
Now I found this in another thread: ( http://forums.civfanatics.com/showpost.php?p=9037399&postcount=4 )

Spoiler :






the part with the __import__('funnystuff') would be exactly what i need for the event PythonCallback:
<PythonCallback>__import__('funnystuff').doPyMyModEvent1</PythonCallback>
<PythonCanDo>__import__('funnystuff').candoPyMyModEvent1</PythonCanDo>
<PythonHelp>__import__('funnystuff').helpPyMyModEvent1</PythonHelp>

i tryed it but unfortunately its not working :(
is there some way to add this __improt__ thingy in RifE so it works with the CIV4EventInfos.xml ?

That works, it's just not 'true' modular, as it does not find the python within the module folder but as a new file in Assets/Python.

what do you mean with soon?
i'd like to play rife 1.30 with modular imperial roads! lol

Well, the change is pretty simple and all that's left for 1.31 is defining spawngroups and adjusting lairs (all XML), so it could be in as soon as 1.31 is ready... Just needs to be added by someone. :lol:
 
ok, file "CvRandomEventInterface.py" now should be modular
* all functions from "/[moduleFolder]/python/event*.py" files now will be loaded into CvRandomEventInterface module

(( svn revision 114, most likely will be in RifE v1.31 ))

edit: ... ninja'd on forums by two people (( odalrick, Valkrionn )) in one day (( today )) in one thread (( this one )) on my own project topic (( MPL )) ... great
 
so i noticed that a lot of the python code has been written differently, and i was wondering what the implications of this were (if there were any) such as, can i just keep writing code the way it used to be done, or am i going to have to relearn it?

Also, im a little unsure how modular python works, could someone explain this?
 
so i noticed that a lot of the python code has been written differently, and i was wondering what the implications of this were (if there were any) such as, can i just keep writing code the way it used to be done, or am i going to have to relearn it?

Also, im a little unsure how modular python works, could someone explain this?

If you mean the dicts... That's just a performance thing, the old method still works fine.

As for MPL... It's not too complex, and there are good examples in the Mekara module. For each file, you need a few specific lines (Which ones depend on the file type (Spell, Event, Utils, RandomEvent); Check the very top of the base file, lines such as those in the code block below should be included), and then the functions.

For Spells and RandomEvent, your functions are simple, exactly the same as you'd add a new function to the base files. Nothing new.

For Event and Utils, it's a bit different, as you don't define new functions but modify existing ones. To do this, though, you simply clone the function header (ex: def cannotTrain(self,argsList): , and then whatever variable definitions below it you happen to need), and then add code as normal. Again, not really difficult.

Code:
from CvPythonExtensions import *
import PyHelpers
import CvEventInterface
import CvUtil
 
Top Bottom