Sid Meier's Civilization V

Sid Meier's Civilization V

Not enough ratings
Machiavelli's snippets for mod makers
   
Award
Favorite
Favorited
Unfavorite
Description
This collection contains the various snippets I've placed on the workshop. These snippets provide functionality that other mod makers may find useful in their own projects.

If an end-user is playing with multiple mods that use any of these snippets it will work properly. The parenthesis after each mod indicate what versions of civ (Vanilla, G&K, BNW) the snippet will work with.

If you use a snippet in your mod please subscribe to the snippet so you will know if the snippet you are using is updated in the future. Most snippets are mature and unlikely to be changed but if any errors need to be fixed or enhancements made they could be updated. Please include a note telling other mod makers to go here if they want to use one of these snippets. That way they get the latest and greatest version of the snippet.

--- Unit Created Event (Vanilla, G&K, BNW) ------------------------------------------
This mod contains code that defines a lua event that fires off when a unit is created. The event does not fire when a unit is upgraded. The lua event provides the information you need to get the owning player object and the unit object.

--- Building Created Event (Vanilla, G&K, BNW) ------------------------------------------
This mod contains code that defines a lua event that fires off when a building is created. The event does not fire for buildings with 0 or less hammer cost unless they have a faithCost greater than zero and are enabledByBelief. The lua event provides the information you need to get the city object and the buildingclass.

--- Policies grant buildings (Vanilla, G&K, BNW) ------------------------------------------
This mod contains code that defines three new XML tables. By adding entries to these tables mod makers can have Social Policies grant buildings in cities.

Policy_FreeBuildingClass: <PolicyType, BuildingClass>
The building will be granted to every city.

Policy_FreeBuildingClassCapital: <PolicyType, BuildingClass>
The building will be granted to only the capital. If the capital moves (due to conquest) the building automatically moves.

Policy_FreeBuildingClassCityStates: <PolicyType, BuildingClassType>
The building will be granted to captured city-states.

--- Religion snippets (G&K, BNW) ------------------------------------------
This mod contains code that defines two lua events and a new XML table:

LuaEvents.CityAdoptsReligionEvent(iOwner, iX, iY, eOldReligion, eNewReligion, bFirstConversion)
A LUA event that fires when a city adopts a religion.

LuaEvents.ReligionFoundedEvent(founderID, iX, iY, eOldReligion, eNewReligion)
A LUA event that fires when a religion is founded.

Belief_FounderFreeBuildingClassCapital: <BeliefType, BuildingClassType>
A table that will grant the building to the player's capital if they have the founder belief. If their capital moves (due to conquest) than the building automatically moves.

Each snippet depend on the snippets above it. Meaning you must use "CityAdoptsReligionEvent" for either of the other snippets to work. And you must be using "ReligionFoundedEvent" for the Belief_FounderFreeBuildingClassCapital table to work.

--- Religions grant buildings (G&K, BNW) ------------------------------------------
This mod contains code that defines a new XML tables. By adding entries to these tables mod makers can have Religions (not beliefs) grant buildings in cities.

Religion_FreeBuildingClass: <ReligionType, BuildingClass>
When this religion becomes the majority in a city, the city will be granted this building. If the religion stops being the majority the building is removed.

--- Buildings require empire resources (Vanilla, G&K, BNW) ------------------------------------------
This mod contains code that defines two new XML tables. By adding entries to these tables mod makers can have Buildings that can only be built if the player has access to resources somewhere in their empire. Unlike the "Building_LocalResource" tables the resources do not have to be within the city's limits. Unlike "Building_ResourceQuantityRequirements" the resource is not consumed.
Items (6)
Unit Created Event [snippet for mod makers]
Created by Machiavelli
For mod makers. What it does This mod contains code that defines a lua event that fires off when a unit is created. The event does not fire when a unit is upgraded. The lua event provides the information you need to get the owning player object and the uni...
Building Created Event [snippet for mod makers]
Created by Machiavelli
For mod makers. What it does This mod contains code that defines a lua event that fires off when a building is created. The event does not fire for buildings with 0 or less hammer cost unless they have a faithCost greater than zero and are enabledByBelief....
Policies Grant Buildings [snippet for mod makers]
Created by Machiavelli
For mod makers. What it does This mod contains code that defines three new XML tables. By adding entries to these tables mod makers can have Social Policies grant buildings in cities. If an end-user is playing with multiple mods that use this snippet it wi...
Religion Snippets [for mod makers]
Created by Machiavelli
For mod makers. What it does This mod contains code that defines two lua events and a new XML table: LuaEvents.CityAdoptsReligionEvent(iOwner, iX, iY, eOldReligion, eNewReligion, bFirstConversion) A LUA event that fires when a city adopts a religion. LuaEv...
Religions Grant Buildings [snippet for mod makers]
Created by Machiavelli
For mod makers. What it does This mod contains code that defines a new XML tables. By adding entries to these tables mod makers can have Religions (not beliefs) grant buildings in cities. Religion_FreeBuildingClass: <ReligionType, BuildingClass> When this ...
Buildings require empire resources [snippet for mod makers]
Created by Machiavelli
For mod makers. What it does This mod contains code that defines two new XML tables. By adding entries to these tables mod makers can have Buildings that can only be built if the player has access to resources somewhere in their empire. Unlike the "Buildin...