new Map(dataopt)
- Source:
Create a Map instance
Example
// returns a new Map
const { Map, Room } = require('lucid-dream');
const map = new Map({
package: 'mypackage',
rooms: [ new Room([ 0, 0 ]) ]
});
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object |
<optional> |
{}
|
An object defining the properties of the map Properties
|
Methods
(async) decode(file) → {Object}
- Source:
Decodes a map from a .bin
file
Example
// decodes a map
const { Map } = require('lucid-dream');
const map = new Map();
const decodedMap = await map.decode('/path/to/my-map.bin');
Parameters:
Name | Type | Description |
---|---|---|
file |
String | The path to the |
Returns:
The decoded map data
- Type
- Object
(async) encode(data, file) → {null}
- Source:
Encodes map data to a .bin
file
Example
// encodes a map to a .bin file
const { Map } = require('lucid-dream');
const map = new Map();
await map.decode('/path/to/my-map.bin');
// make your changes to the map
await map.encode(map.data, '/path/to/my-new-map.bin');
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | Map data |
file |
String | The path to the |
Returns:
- Type
- null
toDict() → {Object}
- Source:
Encode a map into a dictionary
Example
// returns encoded map dictionary
const { Map } = require('lucid-dream');
const map = new Map();
map.toDict();
Returns:
An object containing the encoded map dicitonary
- Type
- Object