Data
Description:
A singleton object that provides a centralized location for storing and accessing game-related data.
Data.Relation
Type: Enumeration.
Description:
An enum representing the possible relations between two groups.
Signature:
enum Relation
"Enemy"
"Friend"
"Neutral"
"Unknown"
"Any"
end
groupFirstPlayer
Type: Readonly Field.
Description:
A group key representing the first index for a player group.
Signature:
const groupFirstPlayer: integer
groupLastPlayer
Type: Readonly Field.
Description:
A group key representing the last index for a player group.
Signature:
const groupLastPlayer: integer
groupHide
Type: Readonly Field.
Description:
A group key that won't have any contact with other groups by default.
Signature:
const groupHide: integer
groupDetectPlayer
Type: Readonly Field.
Description:
A group key that will have contacts with player groups by default.
Signature:
const groupDetectPlayer: integer
groupTerrain
Type: Readonly Field.
Description:
A group key representing terrain that will have contacts with other groups by default.
Signature:
const groupTerrain: integer
groupDetection
Type: Readonly Field.
Description:
A group key that will have contacts with other groups by default.
Signature:
const groupDetection: integer
store
Type: Readonly Field.
Description:
A dictionary that can be used to store arbitrary data associated with string keys and various values globally.
Signature:
const store: Dictionary
setShouldContact
Type: Function.
Description:
A function that can be used to set a boolean value indicating whether two groups should be in contact or not.
Signature:
setShouldContact: function(self: Data, groupA: integer, groupB: integer, contact: boolean)
Parameters:
Parameter | Type | Description |
---|---|---|
groupA | integer | An integer representing the first group. |
groupB | integer | An integer representing the second group. |
contact | boolean | A boolean indicating whether the two groups should be in contact. |
getShouldContact
Type: Function.
Description:
A function that can be used to get a boolean value indicating whether two groups should be in contact or not.
Signature:
getShouldContact: function(self: Data, groupA: integer, groupB: integer): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
groupA | integer | An integer representing the first group. |
groupB | integer | An integer representing the second group. |
Returns:
Return Type | Description |
---|---|
boolean | Whether the two groups should be in contact. |
setRelation
Type: Function.
Description:
A function that can be used to set the relation between two groups.
Signature:
setRelation: function(self: Data, groupA: integer, groupB: integer, relation: Relation)
Parameters:
Parameter | Type | Description |
---|---|---|
groupA | integer | An integer representing the first group. |
groupB | integer | An integer representing the second group. |
relation | Relation | The relation between the two groups. |
getRelation
Type: Function.
Description:
A function that can be used to get the relation between two groups.
Signature:
getRelation: function(self: Data, groupA: integer, groupB: integer): Relation
Parameters:
Parameter | Type | Description |
---|---|---|
groupA | integer | An integer representing the first group. |
groupB | integer | An integer representing the second group. |
Returns:
Return Type | Description |
---|---|
Relation | The relation between the two groups. |
getRelation
Type: Function.
Description:
A function that can be used to get the relation between two bodies.
Signature:
getRelation: function(self: Data, bodyA: Body, bodyB: Body): Relation
Parameters:
Parameter | Type | Description |
---|---|---|
bodyA | Body | The first body. |
bodyB | Body | The second body. |
Returns:
Return Type | Description |
---|---|
Relation | The relation between the two bodies. |
isEnemy
Type: Function.
Description:
A function that returns whether two groups have an "Enemy" relation.
Signature:
isEnemy: function(self: Data, groupA: integer, groupB: integer): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
groupA | integer | An integer representing the first group. |
groupB | integer | An integer representing the second group. |
Returns:
Return Type | Description |
---|---|
boolean | Whether the two groups have an "Enemy" relation. |
isEnemy
Type: Function.
Description:
A function that returns whether two bodies have an "Enemy" relation.
Signature:
isEnemy: function(self: Data, bodyA: Body, bodyB: Body): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
bodyA | Body | The first body. |
bodyB | Body | The second body. |
Returns:
Return Type | Description |
---|---|
boolean | Whether the two bodies have an "Enemy" relation. |
isFriend
Type: Function.
Description:
A function that returns whether two groups have a "Friend" relation.
Signature:
isFriend: function(self: Data, groupA: integer, groupB: integer): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
groupA | integer | An integer representing the first group. |
groupB | integer | An integer representing the second group. |
Returns:
Return Type | Description |
---|---|
boolean | Whether the two groups have a "Friend" relation. |
isFriend
Type: Function.
Description:
A function that returns whether two bodies have a "Friend" relation.
Signature:
isFriend: function(self: Data, bodyA: Body, bodyB: Body): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
bodyA | Body | The first body. |
bodyB | Body | The second body. |
Returns:
Return Type | Description |
---|---|
boolean | Whether the two bodies have a "Friend" relation. |
isNeutral
Type: Function.
Description:
A function that returns whether two groups have a "Neutral" relation.
Signature:
isNeutral: function(self: Data, groupA: integer, groupB: integer): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
groupA | integer | An integer representing the first group. |
groupB | integer | An integer representing the second group. |
Returns:
Return Type | Description |
---|---|
boolean | Whether the two groups have a "Neutral" relation. |
isNeutral
Type: Function.
Description:
A function that returns whether two bodies have a "Neutral" relation.
Signature:
isNeutral: function(self: Data, bodyA: Body, bodyB: Body): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
bodyA | Body | The first body. |
bodyB | Body | The second body. |
Returns:
Return Type | Description |
---|---|
boolean | Whether the two bodies have a "Neutral" relation. |
setDamageFactor
Type: Function.
Description:
A function that sets the bonus factor for a particular type of damage against a particular type of defence. The builtin "MeleeAttack" and "RangeAttack" actions are using simple formular of finalDamage = damage * bonus
.
Signature:
setDamageFactor: function(self: Data, damageType: integer, defenceType: integer, bounus: number)
Parameters:
Parameter | Type | Description |
---|---|---|
damageType | integer | An integer representing the type of damage. |
defenceType | integer | An integer representing the type of defence. |
bonus | number | A number representing the bonus. |
getDamageFactor
Type: Function.
Description:
A function that gets the bonus factor for a particular type of damage against a particular type of defence.
Signature:
getDamageFactor: function(self: Data, damageType: integer, defenceType: integer): number
Parameters:
Parameter | Type | Description |
---|---|---|
damageType | integer | An integer representing the type of damage. |
defenceType | integer | An integer representing the type of defence. |
Returns:
Return Type | Description |
---|---|
number | A number representing the bonus factor. |
isPlayer
Type: Function.
Description:
A function that returns whether a body is a player or not.
This works the same as Data.groupFirstPlayer <= body.group and body.group <= Data.groupLastPlayer
.
Signature:
isPlayer: function(self: Data, body: Body): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
body | Body | The body to check. |
Returns:
Return Type | Description |
---|---|
boolean | Whether the body is a player. |
isTerrain
Type: Function.
Description:
A function that returns whether a body is terrain or not.
This works the same as body.group == Data.groupTerrain
.
Signature:
isTerrain: function(self: Data, body: Body): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
body | Body | The body to check. |
Returns:
Return Type | Description |
---|---|
boolean | Whether the body is terrain. |
clear
Type: Function.
Description:
A function that clears all data stored in the "Data" object, including user data in Data.store field. And reset some data to default values.
Signature:
clear: function(self: Data)