https://modiki.civfanatics.com/api.php?action=feedcontributions&user=Duha&feedformat=atomCivilization Modding Wiki - User contributions [en]2024-03-29T14:32:57ZUser contributionsMediaWiki 1.38.2https://modiki.civfanatics.com/index.php?title=Civ4_Python&diff=4577Civ4 Python2010-07-17T12:57:32Z<p>Duha: /* Tutorials and Reference */</p>
<hr />
<div>== Template ==<br />
Please use the following template for python files.<br />
* [[Format for new Python pages]]<br />
<br />
== Tutorials and Reference ==<br />
<br />
* [http://forums.civfanatics.com/showthread.php?t=154130 TGA's Python Tutorial]<br />
* [http://forums.civfanatics.com/showthread.php?t=163848 How to Call a Function at the End of a Turn]<br />
* [http://apolyton.net/forums/showthread.php?s=&threadid=167960 Jon Shafer's Guide to Python in Civ4]<br />
* [http://forums.civfanatics.com/showthread.php?t=152856 Sample Python Code]<br />
* BTS Python API<br />
** [http://civ4bug.sourceforge.net/PythonAPI/index.html View]<br />
** [http://code.google.com/p/civ4-python-api/ Project @ Google Code]<br />
** [http://forums.civfanatics.com/showthread.php?t=238839 Forum Discussion]<br />
* [http://civilization4.net/files/modding/PythonAPI/ Warlords Python API]<br />
* [http://forums.civfanatics.com/showthread.php?t=323805 Modding CvGameUtils]<br />
* [http://forums.civfanatics.com/showthread.php?t=331001 How to Make Python Action Buttons]<br />
* [http://modiki.civfanatics.com/index.php/Civ4_Python/import Import guide]<br />
<br />
== Files ==<br />
<br />
=== Assets\Python ===<br />
* [[CvAdvisorUtils]]<br />
* [[CvCameraControls]]<br />
* [[CvDebugTools]]<br />
* [[CvDefineEditor]]<br />
* [[CvDiplomacy]]<br />
* [[CvEventManager]]<br />
* [[CvGameUtils]]<br />
* [[CvMagGeneratorUtil]]<br />
* [[CvPerfTest]]<br />
* [[CvQuestManager]]<br />
* [[CvScreenUtils]]<br />
* [[CvUtil]]<br />
* [[DomPyHelpers]]<br />
* [[PyHelpers]]<br />
* [[ScreenImput]]<br />
* [[vector]]<br />
<br />
=== Assets\Python\_DebugTools ===<br />
* [[AudioLogParser]]<br />
<br />
=== Assets\Python\EntryPoints ===<br />
* [[CvAppInterface]]<br />
* [[CvDebugInterface]]<br />
* [[CvDiplomacyInterface]]<br />
* [[CvEventInterface]]<br />
* [[CvGameInterface]]<br />
* [[CvGameInterfaceFile]]<br />
* [[CvMapScriptInterface]]<br />
* [[CvOptionScreenCallbackInterface]]<br />
* [[CvPopupInterface]]<br />
* [[CvRandomEventInterface]]<br />
* [[CvScreensInterface]]<br />
* [[CvScreenUtilsInterface]]<br />
* [[CvTranslator]]<br />
* [[CvUnitControlInterface]]<br />
* [[CvWBInterface]]<br />
* [[PbMain]]<br />
<br />
=== Assets\Python\PitBoss ===<br />
* [[PbAdmin]]<br />
* [[PbWizard]]<br />
<br />
=== Assets\Python\pyHelper ===<br />
* [[Popup]]<br />
* [[Unit]]<br />
* [[UnitEntity]]<br />
<br />
=== Assets\Python\pyUnit ===<br />
* [[CvUnitController]]<br />
<br />
=== Assets\Python\pyWB ===<br />
* [[CvWBDesc]]<br />
* [[CvWBPopups]]<br />
<br />
=== Assets\Python\Screens ===<br />
* [[CvAdvisorScreen]]<br />
* [[CvCivicsScreen]]<br />
* [[CvCorporationAdvisor]]<br />
* [[CvDanQuayle]]<br />
* [[CvDawnOfMan]]<br />
* [[CvDebugInfoScreen]]<br />
* [[CvDomesticAdvisor]]<br />
* [[CvEraMovieScreen]]<br />
* [[CvEspionageAdvisor]]<br />
* [[CvExoticForeignAdvisor]]<br />
* [[CvFinanceAdvisor]]<br />
* [[CvForeignAdvisor]]<br />
* [[CvGFCScreen]]<br />
* [[CvHallOfFameScreen]]<br />
* [[CvInfoScreen]]<br />
* [[CvIntroMovieScreen]]<br />
* [[CvMainInterface]]<br />
* [[CvMilitaryAdvisor]]<br />
* [[CvOptionsScreen]]<br />
* [[CvPediaBonus]]<br />
* [[CvPediaBuilding]]<br />
* [[CvPediaCivic]]<br />
* [[CvPediaCivilization]]<br />
* [[CvPediaCorporation]]<br />
* [[CvPediaFeature]]<br />
* [[CvPediaHistory]]<br />
* [[CvPediaImprovement]]<br />
* [[CvPediaLeader]]<br />
* [[CvPediaMain]]<br />
* [[CvPediaProject]]<br />
* [[CvPediaPromotion]]<br />
* [[CvPediaReligion]]<br />
* [[CvPediaScreen]]<br />
* [[CvPediaSpecialist]]<br />
* [[CvPediaTech]]<br />
* [[CvPediaTerrain]]<br />
* [[CvPediaUnit]]<br />
* [[CvPediaUnitChart]]<br />
* [[CvReligionScreen]]<br />
* [[CvReplayScreen]]<br />
* [[CvScreen]]<br />
* [[CvScreenEnums]]<br />
* [[CvSpaceShipScreen]]<br />
* [[CvTechChooser]]<br />
* [[CvTechSplashScreen]]<br />
* [[CvTopCivs]]<br />
* [[CvTutorialQuestScreen]]<br />
* [[CvUNVictoryScreen]]<br />
* [[CvVictoryMovieScreen]]<br />
* [[CvVictoryScreen]]<br />
* [[CvWonderMovieScreen]]<br />
* [[CvWorldBuilderDiplomacyScreen]]<br />
* [[CvWorldBuilderScreen]]<br />
* [[IconGrid]]<br />
* [[TechTree]]<br />
<br />
=== Assets\Python\System ===<br />
* These files are mostly compiled python files that cannot be modified.<br />
<br />
{{Civ4_Python_Files}}<br />
<br />
[[Category:Civilization 4]]</div>Duhahttps://modiki.civfanatics.com/index.php?title=Civ4_Python/import&diff=4576Civ4 Python/import2010-07-17T12:55:54Z<p>Duha: </p>
<hr />
<div>'''Import guide.'''<br />
<br />
import allow you to add python files to you mod.<br />
<br />
'''Example:'''<br />
<br />
How to add popup to the event:<br />
:'''Bad way:''' <br />
* Insert popup code to CvEventManager.py in event.<br /><br />
'''Result:'''<br /><br />
Big files is hard to read and edit. It is not easy to customize this code and merge to others mod.<br /><br />
:'''Good way:'''<br /><br />
* Create file mymod.py<br /><br />
* Create function that runs popup (for example: run_popup)<br /><br />
* edit CvEventManager.py:<br /><br />
** add string after imports: import mymod.py<br /><br />
** and string in event: mymod.run_popup(*args)<br /><br />
'''Result:'''<br /><br />
It is easy to add / remove this function from mod (just uncomment lines).<br /><br />
It is easy to share this function. <br /><br />
It is easy to call this function in other place. (if yon need it on some event).<br /><br />
<br />
import executes script in file (if you have only functions and classes loads them to memory.)<br />
<br />
=='''import sintax:'''==<br />
* ''import mymod''<br /> <br />
to access functions use:<br /><br />
''mymod.foo()''<br /><br />
<br />
* ''from mymod import *''<br /><br />
to access functions use: <br /><br />
''foo()''<br /><br />
<br />
* ''from mymod import foo, goo''<br /><br />
to access functions use: <br /><br />
''foo()'' or ''goo()''<br /><br />
(some IDE has autocomplite feature and in this way shows only foo and goo.)<br />
<br />
* ''from mymod import this_is_long_name_function as foo''<br /><br />
to access functions use:<br /><br />
''foo()''<br /><br />
(It is good idea to have functions with understandable name)<br />
<br />
== '''Import folders''' ==<br />
* Create folder (mymodule)<br />
* Create __init__.py (leave it blank)<br />
* Create file: myscript.py<br />
<br />
'''Usage'''<br /><br />
from mymodule import myscript <br /><br />
or<br /><br />
from mymodule.myscript import *<br /><br />
<br />
<br />
<br />
=='''Import rules:'''==<br />
Use imports at the file beginning!<br />
<br />
== References ==<br />
[http://forums.civfanatics.com/showpost.php?p=2495872 Lesson 09 - 'Borrowing' other people's stuff (with modules)]</div>Duhahttps://modiki.civfanatics.com/index.php?title=Civ4_Python/import&diff=4575Civ4 Python/import2010-07-17T12:39:02Z<p>Duha: </p>
<hr />
<div>import allow you to add python files to you mod.<br />
<br />
'''Example:'''<br />
<br />
How to add popup to the event:<br />
:'''Bad way:''' <br />
* Insert popup code to CvEventManager.py in event.<br /><br />
'''Result:'''<br /><br />
Big files is hard to read and edit. It is not easy to customize this code and merge to others mod.<br /><br />
:'''Good way:'''<br /><br />
* Create file mymod.py<br /><br />
* Create function that runs popup (for example: run_popup)<br /><br />
* edit CvEventManager.py:<br /><br />
** add string after imports: import mymod.py<br /><br />
** and string in event: mymod.run_popup(*args)<br /><br />
'''Result:'''<br /><br />
It is easy to add / remove this function from mod (just uncomment lines).<br /><br />
It is easy to share this function. <br /><br />
It is easy to call this function in other place. (if yon need it on some event).<br /><br />
<br />
import executes script in file (if you have only functions and classes loads them to memory.)<br />
<br />
=='''import sintax:'''==<br />
* ''import mymod''<br /> <br />
to access functions use:<br /><br />
''mymod.foo()''<br /><br />
<br />
* ''from mymod import *''<br /><br />
to access functions use: <br /><br />
''foo()''<br /><br />
<br />
* ''from mymod import foo, goo''<br /><br />
to access functions use: <br /><br />
''foo()'' or ''goo()''<br /><br />
(some IDE has autocomplite feature and in this way shows only foo and goo.)<br />
<br />
* ''from mymod import this_is_long_name_function as foo''<br /><br />
to access functions use:<br /><br />
''foo()''<br /><br />
(It is good idea to have functions with understandable name)<br />
<br />
=='''Import rules:'''==<br />
Use imports at the file beginning!<br />
<br />
== References ==<br />
[http://forums.civfanatics.com/showpost.php?p=2495872|Lesson 09 - 'Borrowing' other people's stuff (with modules)]</div>Duhahttps://modiki.civfanatics.com/index.php?title=Civ4_Python/import&diff=4574Civ4 Python/import2010-07-17T12:21:09Z<p>Duha: </p>
<hr />
<div>import allow you to add python files to you mod.<br />
<br />
'''Example:'''<br />
<br />
How to add popup to the event:<br />
:'''Bad way:''' <br />
* Insert popup code to CvEventManager.py in event.<br /><br />
'''Result:'''<br /><br />
Big files is hard to read and edit. It is not easy to customize this code and merge to others mod.<br /><br />
:'''Good way:'''<br /><br />
* Create file mymod.py<br /><br />
* Create function that runs popup (for example: run_popup)<br /><br />
* edit CvEventManager.py:<br /><br />
** add string after imports: import mymod.py<br /><br />
** and string in event: mymod.run_popup(*args)<br /><br />
'''Result:'''<br /><br />
It is easy to add / remove this function from mod (just uncomment lines).<br /><br />
It is easy to share this function. <br /><br />
It is easy to call this function in other place. (if yon need it on some event).<br /><br />
<br />
import executes script in file (if you have only functions and classes loads them to memory.)<br />
<br />
=='''import sintax:'''==<br />
* ''import mymod''<br /> <br />
to access functions use:<br /><br />
''mymod.foo()''<br /><br />
<br />
* ''from mymod import *''<br /><br />
to access functions use: <br /><br />
''foo()''<br /><br />
<br />
* ''from mymod import foo, goo''<br /><br />
to access functions use: <br /><br />
''foo()'' or ''goo()''<br /><br />
(some IDE has autocomplite feature and in this way shows only foo and goo.)<br />
<br />
* ''from mymod import this_is_long_name_function as foo''<br /><br />
to access functions use:<br /><br />
''foo()''<br /><br />
(It is good idea to have functions with understandable name)<br />
<br />
=='''Import rules:'''==<br />
Use imports at the file beginning!</div>Duhahttps://modiki.civfanatics.com/index.php?title=Civ4_Python/import&diff=4573Civ4 Python/import2010-07-17T10:03:45Z<p>Duha: Created page with 'import allow you to add python files to you mod. Example: adding popup to the start of turn: '''Bad way:''' Insert popup code to CvEventManager.py Big files is hard to read....'</p>
<hr />
<div>import allow you to add python files to you mod.<br />
<br />
Example:<br />
<br />
adding popup to the start of turn:<br />
<br />
'''Bad way:''' <br />
Insert popup code to CvEventManager.py<br />
<br />
Big files is hard to read. It is not easy to customize this code and merge to others mod.<br />
<br />
'''good way'''<br />
Create file mymod.py<br />
Create function that runs popup (run_popup)<br />
edit CvEventManager.py:<br />
<br />
add string after imports:<br />
import mymod.py<br />
<br />
and string: <br />
mymod.run_popup() there it needs.<br />
<br />
It is easy to add / remove this function (just uncomment lines)<br />
It is easy to share.<br />
It is easy to call this function in other place.<br />
<br />
'''import sintax:'''<br />
<br />
import executes file (if you have only functions and classes loads them to memory.)<br />
<br />
import mymod <br />
to access functions use: mymod.foo()<br />
<br />
from mymod import *<br />
to access functions use: foo()<br />
<br />
from mymod import foo, goo<br />
to access functions use: foo()<br />
(some IDE has autocomplite feature and in this way shows only foo and goo. if you don use IDE use *)<br />
<br />
from mymod import this_is_long_name_function as foo<br />
to access functions us: foo()<br />
(It is good idea to have functions with understandable name)<br />
<br />
Import rules:<br />
Use imports at the file beginning.</div>Duha