Difference between revisions of "Packages"

From VCMI Project Wiki
Jump to: navigation, search
(Adding new objects)
(Adding new objects)
Line 19: Line 19:
 
<pre>
 
<pre>
 
id = CreateArtifact(  
 
id = CreateArtifact(  
'CrystalOrb', #reference name
+
'CrystalOrb', #reference name
'Crystal Orb', #actual name in game
+
'Crystal Orb', #actual name in game
Artifact.ART_RELIC, #rarity from namespace Atifact
+
Artifact.ART_RELIC, #rarity from namespace Atifact
Artifact.ART_HERO, #artifact type (including combined artifacts, commander or creature art)
+
Artifact.ART_HERO, #artifact type (including combined artifacts, commander or creature art)
Artifact.ARTPOS_MISC #slot  
+
Artifact.ARTPOS_MISC #slot  
)  
+
)  
 
id.AddBonus (Bonus.SIGHT_RADIOUS,+12) #using namespace Bonus (in Python they are called packages and modules, but that's confusing)
 
id.AddBonus (Bonus.SIGHT_RADIOUS,+12) #using namespace Bonus (in Python they are called packages and modules, but that's confusing)
 
id.price = 8000  
 
id.price = 8000  

Revision as of 15:38, 5 February 2012

Package structure

Packages may consist of following files:

  • mod.py - main file required by Mod Handler. Includes unique name and version of package. Lists all related files included in mod.
  • Script defining new objects and requesting Mod Handler to put them in game.
  • Graphics files
  • Sound files
  • Additional Python script files (.py)
  • Additional text files
  • Possibly .json files

All files should be placed within the scope of root folder of mod.py file. Mods folder in main VCMI directory is scanned upon entering "new game" menu in search of mod.py files.

Adding new objects

An example pseudo-code in Python for adding new artifact:

id = CreateArtifact( 
		'CrystalOrb', #reference name
		'Crystal Orb', #actual name in game
		Artifact.ART_RELIC, #rarity from namespace Atifact
		Artifact.ART_HERO, #artifact type (including combined artifacts, commander or creature art)
		Artifact.ARTPOS_MISC #slot 
		) 
id.AddBonus (Bonus.SIGHT_RADIOUS,+12) #using namespace Bonus (in Python they are called packages and modules, but that's confusing)
id.price = 8000 
id.AIValue = 12000 
id.description = ParseTextFile ('.\CrystalOrb.txt') 
SetArtifactDef ('CrystalOrb','.\lodfile\orb.def') 
ArtHandler.SetArtAvaliable ('CrystalOrb')