data-types
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | data-types [2021/06/18 15:46] – maxime | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Data types ====== | ||
+ | ---- | ||
+ | |||
+ | ==== boolean ==== | ||
+ | |||
+ | <file lua> | ||
+ | local value = true | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== integer ==== | ||
+ | |||
+ | Integer number | ||
+ | |||
+ | <file lua> | ||
+ | local value = 42 | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== float ==== | ||
+ | |||
+ | Floating-point number with single precision | ||
+ | |||
+ | <file lua> | ||
+ | local value = 17.44 | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== double ==== | ||
+ | |||
+ | Floating-point number with double precision | ||
+ | |||
+ | <file lua> | ||
+ | local value = -61.7267023355 | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== string ==== | ||
+ | |||
+ | <file lua> | ||
+ | local value = " | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== vec2i ==== | ||
+ | |||
+ | 2D integer vector | ||
+ | |||
+ | To initialize a '' | ||
+ | <file lua> | ||
+ | local value = { 54, 97 } | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== vec2f ==== | ||
+ | |||
+ | 2D float vector | ||
+ | |||
+ | To initialize a '' | ||
+ | <file lua> | ||
+ | local value = { 73.0, 15.66 } | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== vec3i ==== | ||
+ | |||
+ | 3D integer vector | ||
+ | |||
+ | To initialize a '' | ||
+ | <file lua> | ||
+ | local value = { 19, 86, 45 } | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== vec3f ==== | ||
+ | |||
+ | 3D float vector | ||
+ | |||
+ | To initialize a '' | ||
+ | <file lua> | ||
+ | local value = { -15.71, -71.0, 93.03 } | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== quaternion ==== | ||
+ | |||
+ | 4D float vector representing a rotation | ||
+ | |||
+ | To initialize a '' | ||
+ | <file lua> | ||
+ | local value = { 0.302268, 0.075567, 0.6347627, 0.7071068 } | ||
+ | </ | ||
+ | |||
+ | Quaternion properties can also be set with a '' | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== color ==== | ||
+ | |||
+ | A color is stored as four float numbers, representing the four channels. Each channel can have a value superior to 1, in case of HDR use. | ||
+ | |||
+ | To initialize a '' | ||
+ | <file lua> | ||
+ | local value = { 1, 0.549, 0, 0.9 } | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== polygon ==== | ||
+ | |||
+ | A 2D polygon is a list of 2D points ('' | ||
+ | |||
+ | To initialize a square polygon with a side length of '' | ||
+ | <file lua> | ||
+ | local value = { | ||
+ | { 5.5, 5.5 }, | ||
+ | { 5.5, -3.5 }, | ||
+ | { -3.5, -3.5 }, | ||
+ | { -3.5, 5.5 } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | You can also create simple polygons with the following functions: | ||
+ | |||
+ | * '' | ||
+ | |||
+ | ^ Name ^ Type ^ Description ^ | ||
+ | | //'' | ||
+ | | //'' | ||
+ | |||
+ | * '' | ||
+ | |||
+ | ^ Name ^ Type ^ Description ^ | ||
+ | | //'' | ||
+ | | //'' | ||
+ | | //'' | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== bitfield ==== | ||
+ | |||
+ | A bitfield is a dictionary with enumeration values of a specific type as keys, and boolean values as value. | ||
+ | |||
+ | When defining a new object, a enumeration value missing from a bitfield table will be considered as false. When [[: | ||
+ | |||
+ | To initialize a bitfield of [[api: | ||
+ | <file lua> | ||
+ | local bitfield = { | ||
+ | DEFAULT = true, | ||
+ | NAVIGABLE = false, | ||
+ | GRASS_CLEAR = true | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== list ==== | ||
+ | |||
+ | A list is a collection of values of a specific type. This type can be used to create new properties for [[custom-classes|custom classes]]. The following example shows how to declare a '' | ||
+ | |||
+ | <file lua> | ||
+ | Properties = { | ||
+ | ... | ||
+ | { | ||
+ | Name = " | ||
+ | Type = " | ||
+ | Default = { 1.0, -4.0, 5.0 }, -- default value: list with three float numbers | ||
+ | }, | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | ... | ||
+ | |||
+ | mod: | ||
+ | mod: | ||
+ | </ | ||
+ | |||
+ | ==== fixed_sized_array ==== | ||
+ | |||
+ | A fixed sized array is a list containing a fixed number of values of a specific type. This type of property is specified with it's size (e.g. '' | ||
+ | |||
+ | <file lua> | ||
+ | Properties = { | ||
+ | ... | ||
+ | { | ||
+ | Name = " | ||
+ | Type = " | ||
+ | Default = { " | ||
+ | }, | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | ... | ||
+ | |||
+ | mod: | ||
+ | </ | ||
+ | |||
+ | ==== fixed_sized_map ==== | ||
+ | |||
+ | A fixed sized map is very similar to a fixed sized array, except it can only take enumeration values as keys. For some properties, a maximum key value can be specified. | ||
+ | |||
+ | With a fixed sized map of [[data-types# | ||
+ | |||
+ | <file lua> | ||
+ | someType.MyMapProperty[BUILDING_TYPE.GENERAL] = 4.2 | ||
+ | someType.MyMapProperty[" | ||
+ | </ |
data-types.txt · Last modified: 2023/09/14 14:52 by polymorphgames