[*Back to Index*](index.md.html)
# Effects
Effects are a powerful tool for implementing gameplay effects for Mission Sponsors, Commander Profiles or Game Rules mod items. They can also be used to modify the game unconditionally whenever the mod is loaded, when placed in a [Global Effects](ModItemGlobalEffects.md.html) mod item. Some of them make use of [global consts](LuaFunctionDoc_Consts.md.html) to influence the gameplay.
## Code Effects
The two functions supplied here are called at game start and the desired game logic can be put into either one of them. They are however called at different times and therefore suitable for different types of logic. This should be taken into careful consideration when deciding on the most appropriate one. When unsure about which function to use, *OnApplyEffect()* is the safer choice.
The object city, passed as an argument to both of the functions, gives access to various functions and variables of high importance to the gameplay. The City.lua file in the Lua source code can be used as a a further point of reference and is available at https://github.com/HaemimontGames/SurvivingMars
function OnInitEffect(self, city, parent)
: This function is called early during the player setup. Code here should not assume that gameplay structures are already inited and try to interract with them. Here can be placed code for locking and unlocking certain gameplay elements (buildings, traits, etc.)
function OnApplyEffect(self, city, parent)
: This function is called later in the player setup. Here is the place to modify and interract with existing gameplay objects, as they are now already initialized.
## Funding
Funding (M)
: The funding available at the beginning of the mission, in millions.
## Compound Efficiency
Label
: The game object whose propery is being modified
Threshold
: The minimum number of objects with this property needed for the effect to be applied
Property
: The property which is being modified
Amount
: The amount to be added to the propery value
Percent
: The percent by which the property value will be increased
## Grant Tech
Start with a researched technology
Field
: The field the technology belongs to
Technology
: The technology granted at the beginning of the game
## Modify Construction Cost
Change the construction cost of a single building or a category of buildings
Category
: All the buildings in the chosen cathegry will be infulenced by the effect. For influencing a single building only, leave this empty.
Building
: The building to be influenced
Resource
: Resource needed for constructing the building, influenced by the effect
Percent
: The percent by which the resource needed for construction will be increased
## Modify Label
Modify a game object's property
Label
: The game object whose propery is being modified
Property
: The property which is being modified
Amount
: The amount to be added to the propery value
Percent
: The percent by which the property value will be increased
## Modify Label Over Time
Modify a game object's property over time
Label
: The game object whose propery is being modified
Property
: The property which is being modified
Amount
: The amount to be added to the propery value
Percent
: The percent by which the property value will be increased
Time Interval
: The interval between the repetitions
Time Units
: The units in which the time interval is being calculated
Repetitions
: The numeber of repetitions during the game
## Modify Resupply Parameter
Modifies the weight or the price of a certain item supplied from earth
Item
: The item whose property will be modified
Parameter
: The property which will be modified; cna be eithe price or weight
Percent
: The percent by which the property value will be increased
## Modify Upgrade
Modifies a certain building property when the building is updated
Upgrade
: The building whose update will be influenced
Property
: The property which is being modified
Amount
: The amount to be added to the propery value
Percent
: The percent by which the property value will be increased
## Unlock Building
Unlocks a building at the start of the game
Building
: The building to be unlocked on game start
Hide Building
: Whether the building should be hidden
## Unlock Deeper Deposits
Depth Levels to unlock
: The desired depth to be unlocked on game start
## Unlock Resupply Item
Item
: Item to be unlocked on game start for the resupply rockets
## Unlock Trait
Trait
: The colonist trait to be unlocked on game start
## Unlock upgrade
Upgrade
: The building upgrade to be unlocked on game start