sm.terrainTile

Reads .tile file data

Constants

Name Type Description
loadFlags table List of flags for use with getContentFromPrefab.

loadFlags

Value type: table

Prefab content load flags.

{
    creations,
    nodes,
    assets,
    decals,
    harvestables,
    kinematics,
    voxelMeshes,
    all,
}

Functions

getAssetsForCell

sm.terrainTile.getAssetsForCell( tileUid, cellOffsetX, cellOffsetY, sizeLevel )

Returns a table of all assets in a terrain cell.

Parameters:

Name Type Description
tileUid Uuid The tile uuid.
cellOffsetX integer The cell X offset.
cellOffsetY integer The cell Y offset.
sizeLevel integer The size level of asset. [0-3]

Returns:

Type Description
table A table { { uuid = Uuid, pos = Vec3, rot = Quat, colors = { string = Color, ...}, tags = { string, ... } }, ... } of assets in the cell.

getClutterIdxAt

sm.terrainTile.getClutterIdxAt( tileUid, cellOffsetX, cellOffsetY, x, y )

Returns the clutter index at position (x,y) in a tile cell.

Parameters:

Name Type Description
tileUid Uuid The tile uuid.
cellOffsetX integer The cell X offset.
cellOffsetY integer The cell Y offset.
x integer The local X value.
y integer The local Y value.

Returns:

Type Description
integer The clutter index.

getColorAt

sm.terrainTile.getColorAt( tileUid, cellOffsetX, cellOffsetY, lod, x, y )

Returns the terrain color at position (x,y) in a tile cell.

Parameters:

Name Type Description
tileUid Uuid The tile uuid.
cellOffsetX integer The cell X offset.
cellOffsetY integer The cell Y offset.
lod integer The level of detail. [0-5]
x integer The local X value.
y integer The local Y value.

Returns:

Type Description
number
number
number
The color R, G, B values.

getContentFromPrefab

sm.terrainTile.getContentFromPrefab( prefabPath, loadFlags )

Returns the content of a prefab.

Return value 1: A table of creations in the prefab. { { name = string, pos = Vec3, rot = Quat, sortingIndex = integer, tags = { string, ... } }, ... }

Return value 2: A table of prefabs in the prefab. { { name = string, pos = Vec3, rot = Vec3, scale = Vec3, tags = { string, ... }, flags = integer }, ... }

Return value 3: A table of nodes in the prefab. { { pos = Vec3, rot = Quat, scale = Vec3, tags = { string, ... }, params = table } }

Return value 4: A table of assets in the prefab. { { uuid = Uuid, pos = Vec3, rot = Quat, slopeNormal = Vec3, colors = { string = Color, ...}, tags = { string, ... } }, ... }

Return value 5: A table of decals in the prefab. { { pos = Vec3, rot = Vec3, scale = Vec3, decalId = integer, color = Color, layer = integer, tags = { string, ... } }, ... }

Return value 6: A table of harvestables in the prefab. { {uuid = Uuid, pos = Vec3, rot = Quat, color = Color, params = table, tags = { string, ... } }, ... }

Return value 7: A table of kinematics in the prefab. { {uuid = Uuid, pos = Vec3, rot = Quat, scale = Vec3, color = Color, params = table, tags = { string, ... } }, .. }

Return value 8: A table containing the min and max bounds of the prefab. { min = Vec3, max = Vec3 }

Parameters:

Name Type Description
prefabPath string The path to the prefab file.
loadFlags (optional) integer A mask of content to load. Defaults to all objects (optional)

Returns:

Type Description
table
table
table
table
table
table
table
table
Prefab content tables.

getCreationsForCell

sm.terrainTile.getCreationsForCell( tileUid, cellOffsetX, cellOffsetY )

Returns a table of all creations in a terrain cell.

Parameters:

Name Type Description
tileUid Uuid The tile uuid.
cellOffsetX integer The cell X offset.
cellOffsetY integer The cell Y offset.

Returns:

Type Description
table A table { { pathOrJson = string, pos = Vec3, rot = Quat }, ... } of creations in the cell.

getCreatorId

sm.terrainTile.getCreatorId( path )

Returns the id of the tiles creator.

Parameters:

Name Type Description
path string The tile's path.

Returns:

Type Description
string The creator's id.

getDecalsForCell

sm.terrainTile.getDecalsForCell( tileUid, cellOffsetX, cellOffsetY )

Returns all decals for a cell in a tile.

Parameters:

Name Type Description
tileUid Uuid The tile uuid.
cellOffsetX integer The cell X offset.
cellOffsetY integer The cell Y offset.

Returns:

Type Description
table A table { { pos = Vec3, rot = Vec3, scale = Vec3, decalId = integer, color = Color, layer = integer, tags = { string, ... } }, ... } of decals in the cell.

getHarvestablesForCell

sm.terrainTile.getHarvestablesForCell(
    tileUid,
    cellOffsetX,
    cellOffsetY,
    sizeLevel
)

Returns a table of all harvestables in a terrain cell.

Parameters:

Name Type Description
tileUid Uuid The tile uuid.
cellOffsetX integer The cell X offset.
cellOffsetY integer The cell Y offset.
sizeLevel integer The size level of harvestables. [0-3]

Returns:

Type Description
table A table { {uuid = Uuid, pos = Vec3, rot = Quat, color = Color, params = table, tags = { string, ... } }, ... } of harvestables in the cell.

getHeightAt

sm.terrainTile.getHeightAt( tileUid, cellOffsetX, cellOffsetY, lod, x, y )

Returns the terrain height at position (x,y) in a tile cell.

Parameters:

Name Type Description
tileUid Uuid The tile uuid.
cellOffsetX integer The cell X offset.
cellOffsetY integer The cell Y offset.
lod integer The level of detail. [0-5]
x integer The local X value.
y integer The local Y value.

Returns:

Type Description
number The height.

getKinematicsForCell

sm.terrainTile.getKinematicsForCell(
    tileUid,
    cellOffsetX,
    cellOffsetY,
    sizeLevel
)

Returns a table of all kinematics in a terrain cell.

Parameters:

Name Type Description
tileUid Uuid The tile uuid.
cellOffsetX integer The cell X offset.
cellOffsetY integer The cell Y offset.
sizeLevel integer The size level of kinematics. [0-3]

Returns:

Type Description
table A table { {uuid = Uuid, pos = Vec3, rot = Quat, scale = Vec3, color = Color, params = table, tags = { string, ... } }, .. } of kinematics in the cell.

getMaterialAt

sm.terrainTile.getMaterialAt( tileUid, cellOffsetX, cellOffsetY, lod, x, y )

Returns the terrain material at position (x,y) in a tile cell.

Parameters:

Name Type Description
tileUid Uuid The tile uuid.
cellOffsetX integer The cell X offset.
cellOffsetY integer The cell Y offset.
lod integer The level of detail. [0-5]
x integer The local X value.
y integer The local Y value.

Returns:

Type Description
number
number
number
number
number
number
number
number
Material weights 1-8.

getNodesForCell

sm.terrainTile.getNodesForCell( tileUid, cellOffsetX, cellOffsetY )

Returns all nodes for a cell in a tile.

Parameters:

Name Type Description
tileUid Uuid The tile uuid.
cellOffsetX integer The cell X offset.
cellOffsetY integer The cell Y offset.

Returns:

Type Description
table A table { { pos = Vec3, rot = Quat, scale = Vec3, tags = { string, ... }, params = table } } of nodes in the cell.

getPrefabsForCell

sm.terrainTile.getPrefabsForCell( tileUid, cellOffsetX, cellOffsetY )

Returns all prefabs in a cell.

Parameters:

Name Type Description
tileUid Uuid The tile uuid.
cellOffsetX integer The cell X offset.
cellOffsetY integer The cell Y offset.

Returns:

Type Description
table A table { { name = string, pos = Vec3, rot = Vec3, scale = Vec3, tags = { string, ... }, flags = integer }, ... } of prefabs in the cell.

getSize

sm.terrainTile.getSize( path )

Returns the size of a tile as the number of cells along one of the axises.

Parameters:

Name Type Description
path string The tile's path.

Returns:

Type Description
integer The size.

getTileUuid

sm.terrainTile.getTileUuid( path )

Returns the uuid for a tile file.

Parameters:

Name Type Description
path string The tile's path.

Returns:

Type Description
Uuid The tile's uuid.