Skip to content

Entity API Documentation

DetectiveSmith edited this page Mar 8, 2015 · 4 revisions

Entity.updateEntities()

Updates all entities, checking if they should still exist or not.

Entity.getEntities()

Return Value: table playerData

Gets the data for all entities, indexed by their ID (IDs in this case would be similar in the way a name is for the player).

Entity.spawnEntity(number entityID, number dimension, number x, number y, table overrideTable)

Spawns in an entity using the given arguments. entityID is the asset ID of the entity. All other functions refer to entityID as the entity's ID in the world. To get an entity's ID, use the function 'Entity.getEntities()'. overrideTable is used to override the default values that the entity would spawn with in it's data (such as health, or direction).

Entity.removeEntity(number entityID)

Removes an entity from the world.

Entity.setDirection(number entityID, number newDirection)

Sets the direction of an entity. newDirection can be a number from one to four.

Entity.getDirection(number entityID)

Return Value: number Direction

Gets the ID for an entity.

Entity.setHealth(number entityID, number healthAmount)

Sets the health for an entity.

Entity.getHealth(number entityID)

Return Value: number healthAmount

Returns the amount of health a given entity has currently.

Entity.setCoordinates(number entityID, number x, number y)

Sets the coordinates for an entity.

Entity.getCoordinates(number entityID)

Return Value: number X, number Y

Returns the current position for an entity.

Entity.setDimension(number entityID, number dimension)

Sets the dimension of an entity. dimension can always be a value from -3 to 1, but some mods may add extra dimensions.

Entity.getDimension(number entityID)

Return Value: number Dimension

Returns the current dimension of an entity.

Entity.equipItem(number entityID, number assetID)

Equips the entity with whatever asset assetID refers to. assetID can be any asset.

Entity.getHeldItem(number entityID)

Return Value: number assetID

Returns the asset ID of what they are currently using.

Entity.move(number entityID, number moveAmount, boolean checkForCollision)

Moves an entity moveAmount times in the direction they're currently facing in. Set checkForCollision as true if you want the entity to be able to move through blocks.

(To do) Entity.attack(number entityID, string playerName)

This function needs to be completed.

Clone this wiki locally