Skip to main content

sm.cell

The cell library provides methods to fetch information from terrain cells during the world loading process.
These methods are usually used in the cell load callbacks in the World Script Class.

Functions

getHarvestables

local harvestables = sm.cell.getHarvestables(x, y, size)

Server-Only

Returns an array of harvestables in the cell at the given index that match the given size.

Sizes are:
0: Tiny - plants and crops.
1: Small - small trees and rocks.
2: Medium - medium trees, visible at a long distance.
3: Large - large trees, visible at a very long distance.

Parameters:

  • x (int): The X index.
  • y (int): The Y index.
  • size (int): The harvestable size (defaults to all).

Returns:

  • harvestables (table): The array of harvestables matching the given size.

getInteractablesByAnyUuid

local interactables = sm.cell.getInteractablesByAnyUuid(x, y, uuids)

Server-Only

Returns an array of Interactables in the cell at the given index that match any of the given Uuids.

note

This is only usable in a server_onCellLoaded callback.

Parameters:

  • x (int): The X index.
  • y (int): The Y index.
  • uuids (table): The array of UUIDs to match interactables against.

Returns:

  • interactables (table): The array of interactables matching any of the given UUIDs.

getInteractablesByTag

local interactables = sm.cell.getInteractablesByTag(x, y, tag)

Server-Only

Returns an array of Interactables in the cell at the given index that contain the given tag.

note

This is only usable in a server_onCellLoaded callback.

Parameters:

  • x (int): The X index.
  • y (int): The Y index.
  • tag (string): The tag to match with.

Returns:

  • interactables (table): The array of interactables matching the given tag.

getInteractablesByTags

local interactables = sm.cell.getInteractablesByTags(x, y, tags)

Server-Only

Returns an array of Interactables in the cell at the given index that contain all of the given tags.

note

This is only usable in a server_onCellLoaded callback.

Parameters:

  • x (int): The X index.
  • y (int): The Y index.
  • tags (table): The array of tags to match with.

Returns:

  • interactables (table): The array of interactables matching the given tags.

getInteractablesByUuid

local interactables = sm.cell.getInteractablesByUuid(x, y, uuid)

Server-Only

Returns an array of Interactables in the cell at the given index that match the given Uuid.

note

This is only usable in a server_onCellLoaded callback.

Parameters:

  • x (int): The X index.
  • y (int): The Y index.
  • uuid (Uuid): The interactable shape UUID.

Returns:

  • (table): The array of interactables matching the given UUID.

getNodesByTag

local nodes = sm.cell.getNodesByTag(x, y, tag)

Server-Only

Returns an array of node data tables in the cell at the given index that contain the given tag.

Parameters:

  • x (int): The X index.
  • y (int): The Y index.
  • tag (string): The tag to match with.

Returns:

  • nodes (table): The array containing node data for each node (see structure below).
Table Structure
{
{
position = Vec3,
rotation = Quat,
scale = Vec3,
tags = {string, ...},
params = {...}
}
}

getNodesByTags

sm.cell.getNodesByTags(x, y, tags)

Server-Only

Returns an array of node data tables in the cell at the given index that contain all of the given tags.

Parameters:

  • x (int): The X index.
  • y (int): The Y index.
  • tags (table): The array of tags to match with.

Returns:

  • (table): The array containing node data for each node (see structure below).
Table Structure
{
{
position = Vec3,
rotation = Quat,
scale = Vec3,
tags = {string, ...},
params = {...}
}
}

getTags

local tags = sm.cell.getTags(x, y)

Server-Only

Returns an array of tags in the cell at the given index.

Parameters:

  • x (int): The X index.
  • y (int): The Y index.

Returns:

  • tags (table): The array of tags.