User:DonQuich: Difference between revisions

From Civilization Modding Wiki
Jump to navigationJump to search
m (testing my bot)
mNo edit summary
 
(50 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:TerrainID}}''This page is a part of the [[Lua and UI Reference]].''
Developer of the bot that generated the initial versions of the [[Lua and UI Reference (Civ5)]] on mid-2012.


CivFanatics profile: [http://forums.civfanatics.com/member.php?u=210491 DonQuiche]


The 'TerrainID' pseudo-type is actually a regular '''integer'''. <br/>
Pseudo-types do not exist in LUA, they only serve a documentation purpose on the wiki!<br/>


Integers labeled as 'TerrainID' corresponds to the 'ID' column of the [[Civ5Terrains]] XML table.<br/>
== Mods ==
The values in the 'ID' and 'Type' columns are also dynamically stored on startup in the '''TerrainTypes''' LUA enumeration.<br/>
* [http://forums.civfanatics.com/showthread.php?t=436912 Ingame Editor (IGE)]
* [http://forums.civfanatics.com/showthread.php?p=11646470 Reseed]




==TerrainTypes enumeration ==
== My scratchpad: pages to salvage ==
A LUA enumeration is a just a regular table. <br/>
* [[Lua Game Objects/NotificationTypes]]
It is commonly used to store constants, the keys being the constants' names and the pairs the corresponding values.<br/>
* [[SetHappiness]] - Warning and link
 
* [[HasPolicy]] Good example for HasPolicy and [[SetHasPolicy]]
On startup, the game reads the [[Civ5Terrains]] data table and stores key/value pairs in the LUA enumeration. <br/>
* [[GetMinorCivType]] - Good example for player name (add it to Player.GetName?)
The keys are the strings from the 'Type' column and the values are the integers from the 'ID' column.<br/>
* Warning about graphics refresh on SetTerrainType
 
* Warning and code snippet on SetOwner.
 
* Events.ActivePlayerTurnStart - specify human besides of "active" - exclude AI
Below are the values found in an unmodded game updated with Gods & Kings 1.0.1.705 (August 2012).
* [[GameEvents.PlayerCanConstruct(playerID, buildingTypeID)]] - Example of building constructible with a policy.
 
* [[Events.SerialEventCityDestroyed (Civ5 API)]] Advise the reader to see SerialEventCityCaptured or copy/paste.
{|
* [[Events.SpecificCityInfoDirty (Civ5 API)]] : add "Fired when something in a particular city was changed. E.g. building created/sold, specialists reallocated, and some other things. ".
|-
* [[SerialEventCityPopulationChanged]]: fixes the 2k wiki description. Also copy example.
!align="left" |Key
* Events.SerialEventCityCaptured: "fired when city is captured or traded to an another civ. "
!
* GameEvents.UnitGetSpecialExploreTarget(iPlayerID, iUnitID) - appears to be triggered when the 'explore' order is given, or some subset thereof. The unit structure for the relevant unit is manipulated to set the explore target.
!align="left" |Value
|-
|"NO_TERRAIN"
|
|align="right" |-1
|-
|"TERRAIN_GRASS"
|
|align="right" |0
|-
|"TERRAIN_PLAINS"
|
|align="right" |1
|-
|"TERRAIN_DESERT"
|
|align="right" |2
|-
|"TERRAIN_TUNDRA"
|
|align="right" |3
|-
|"TERRAIN_SNOW"
|
|align="right" |4
|-
|"TERRAIN_COAST"
|
|align="right" |5
|-
|"TERRAIN_OCEAN"
|
|align="right" |6
|-
|"TERRAIN_MOUNTAIN"
|
|align="right" |7
|-
|"TERRAIN_HILL"
|
|align="right" |8
|-
|"NUM_TERRAIN_TYPES"
|
|align="right" |9
|}
 
 
 
==Examples==
 
Here is how to use the LUA enumeration to retrieve the ID from the 'type'. The variable 'id' will be assigned the integer value.0.<pre>
local id = TerrainTypes.TERRAIN_GRASS
local id = TerrainTypes["TERRAIN_GRASS"]
</pre>
Here are different ways to query the database to retrieve the ID from the 'type'. The variable 'id' will be assigned the value 0. See also [[Civ5Lua/GameInfo|GameInfo]].<pre>
local id = GameInfo.Civ5Terrains.TERRAIN_GRASS.ID
local id = GameInfo["Civ5Terrains"]["TERRAIN_GRASS"]["ID"]
local id = GameInfo.Civ5Terrains{Type="TERRAIN_GRASS"}().ID
</pre>
Alternatively you could use this ID to retrieve the value of the 'Description' column. Those examples will return and assign ''"TXT_KEY_TERRAIN_GRASS"''.<pre>
local description = GameInfo.Civ5Terrains[0].Description
local description = GameInfo["Civ5Terrains"][0]["Description"]
local description = GameInfo.Civ5Terrains{ID=TERRAIN_GRASS}().Description
</pre>
 
 
==Methods using those identifiers==
*'''void''' [[Civ5Lua/Plot|Plot]]:[[Civ5Lua/Plot/SetTerrainType|SetTerrainType]]([[Civ5Lua/TerrainID|TerrainID]] type)
 
[[Category:Civ5Lua]]

Latest revision as of 08:21, 22 September 2012

Developer of the bot that generated the initial versions of the Lua and UI Reference (Civ5) on mid-2012.

CivFanatics profile: DonQuiche


Mods


My scratchpad: pages to salvage