new Entity(name, data, idopt)
- Source:
Create an instance of Entity. This is not usually invoked directly. Typically to create an Entity, you'd use one of the subclasses attached to the Lucid.Entity namespace.
Example
// creates an entity
const { Entity } = require('lucid-dream');
const entity = new Entity('player', {}, 999);
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
String | The name of the entity. |
||
data |
Object | An object containing the attributes and child nodes to define the entity. |
||
id |
Number |
<optional> |
globalEntityId++
|
The id of the entity. |
Methods
toDict() → {Object}
- Source:
Encode a entity into a dictionary
Example
// returns encoded entity dictionary
const { Entity } = require('lucid-dream');
const entity = new Entity('spinner', {}, 123);
entity.toDict();
Returns:
An object containing the encoded entity dicitonary
- Type
- Object