Skip to main content

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:

ParameterTypeDescription
groupAintegerAn integer representing the first group.
groupBintegerAn integer representing the second group.
contactbooleanA 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:

ParameterTypeDescription
groupAintegerAn integer representing the first group.
groupBintegerAn integer representing the second group.

Returns:

Return TypeDescription
booleanWhether 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:

ParameterTypeDescription
groupAintegerAn integer representing the first group.
groupBintegerAn integer representing the second group.
relationRelationThe 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:

ParameterTypeDescription
groupAintegerAn integer representing the first group.
groupBintegerAn integer representing the second group.

Returns:

Return TypeDescription
RelationThe 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:

ParameterTypeDescription
bodyABodyThe first body.
bodyBBodyThe second body.

Returns:

Return TypeDescription
RelationThe 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:

ParameterTypeDescription
groupAintegerAn integer representing the first group.
groupBintegerAn integer representing the second group.

Returns:

Return TypeDescription
booleanWhether 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:

ParameterTypeDescription
bodyABodyThe first body.
bodyBBodyThe second body.

Returns:

Return TypeDescription
booleanWhether 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:

ParameterTypeDescription
groupAintegerAn integer representing the first group.
groupBintegerAn integer representing the second group.

Returns:

Return TypeDescription
booleanWhether 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:

ParameterTypeDescription
bodyABodyThe first body.
bodyBBodyThe second body.

Returns:

Return TypeDescription
booleanWhether 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:

ParameterTypeDescription
groupAintegerAn integer representing the first group.
groupBintegerAn integer representing the second group.

Returns:

Return TypeDescription
booleanWhether 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:

ParameterTypeDescription
bodyABodyThe first body.
bodyBBodyThe second body.

Returns:

Return TypeDescription
booleanWhether 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:

ParameterTypeDescription
damageTypeintegerAn integer representing the type of damage.
defenceTypeintegerAn integer representing the type of defence.
bonusnumberA 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:

ParameterTypeDescription
damageTypeintegerAn integer representing the type of damage.
defenceTypeintegerAn integer representing the type of defence.

Returns:

Return TypeDescription
numberA 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:

ParameterTypeDescription
bodyBodyThe body to check.

Returns:

Return TypeDescription
booleanWhether 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:

ParameterTypeDescription
bodyBodyThe body to check.

Returns:

Return TypeDescription
booleanWhether 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)