Harvestable
Associated namespace: sm.harvestable
Represents a harvestable object in the game.
Values:
- angularVelocity
- clientPublicData
- id
- initialHash
- initialPosition
- initialRotation
- mass
- material
- materialId
- name
- publicData
- type
- uuid
- velocity
- worldPosition
- worldRotation
Functions:
- applyShakeImpulse
- destroy
- getAabb
- getAngularVelocity
- getClientPublicData
- getColor
- getData
- getId
- getInitialHash
- getLocalAabb
- getMass
- getMaterial
- getMaterialId
- getName
- getPoseWeight
- getPosition
- getPublicData
- getRotation
- getScale
- getSeatCharacter
- getType
- getUuid
- getUvFrameIndex
- getVelocity
- getWorld
- hasSeat
- isCellKinematic
- isKinematic
- setAllSubMeshVisible
- setClientPublicData
- setColor
- setParams
- setPoseWeight
- setPosition
- setPublicData
- setRotation
- setSeatCharacter
- setSubMeshVisible
- setUvFrameIndex
- transformDirection
- transformLocalPoint
- transformPoint
Operations:
| Operation | Return type | Description |
|---|---|---|
| Harvestable == Harvestable | boolean | Checks if two instances of Harvestable refer to the same Harvestable. |
angularVelocity Vec3
Get:
Returns the angular velocity of the harvestable.
clientPublicData table
Get:
Client only
Returns client public data from a harvestable.
Set:
Client only
Sets client public data on a harvestable.
id integer
Get:
Returns the id of a harvestable.
initialHash number
Get:
Gets the initial hash of a kinematic. The initial hash identifies the kinematic by its initial world position, uuid and world id.
This can be used to match kinematics spawned from the same entity in a tile even though each loaded kinematic is technically a different object.
initialPosition Vec3
Get:
Returns the initial world coordinates of a kinematic.
initialRotation Quat
Get:
Returns the initial quaternion rotation of a harvestable.
mass number
Get:
Returns the mass of a harvestable. The mass scales with the harvestable's scale.
material string
Get:
Returns the material name of a harvestable.
materialId integer
Get:
Returns the material id of a harvestable.
name string
Get:
Returns the name of a harvestable.
publicData table
Get:
Server only
Returns (server) public data from a harvestable.
Set:
Server only
Sets (server) public data on a harvestable.
type string
Get:
Returns the type of a harvestable.
uuid Uuid
Get:
Returns the Uuid of the harvestable.
velocity Vec3
Get:
Returns the velocity of the harvestable.
worldPosition Vec3
Get:
Returns the world coordinates of a harvestable.
worldRotation Quat
Get:
Returns the quaternion rotation of a harvestable.
applyShakeImpulse(harvestable, shake)
Client only
Applies a shake impulse to the harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| number | shake | The shake impulse value. |
destroy(harvestable)
Server only
Destroys a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
getAabb(harvestable)
Returns the axis aligned world space bounds of the harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| Vec3,Vec3 | The min and max bounds. |
getAngularVelocity(harvestable)
Returns the angular velocity of the harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The angular velocity. |
getClientPublicData(harvestable)
Client only
Returns client public data from a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| table | The client public data. |
getColor(harvestable)
Returns the color of the harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| Color | The color. |
getData(harvestable)
Get the script data from a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| table | data The script data. |
getId(harvestable)
Returns the id of a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| integer | The harvestable id. |
getInitialHash(harvestable)
Gets the initial hash of a kinematic. The initial hash identifies the kinematic by its initial world position, uuid and world id.
This can be used to match kinematics spawned from the same entity in a tile even though each loaded kinematic is technically a different object.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The kinematic to get the initial hash from. |
Returns:
| Type | Description |
|---|---|
| number | The initial hash. Returns 0 if the harvestable is not kinematic. |
getLocalAabb(harvestable)
Returns the axis aligned local space bounds of the harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| Vec3,Vec3 | The min and max bounds. |
getMass(harvestable)
Returns the mass of a harvestable. The mass scales with the harvestable's scale.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| number | The mass. |
getMaterial(harvestable)
Returns the material name of a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| string | The name of the material. |
getMaterialId(harvestable)
Returns the material id of a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| integer | The id of the material. |
getName(harvestable)
Returns the name of a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| string | The harvestable name. |
getPoseWeight(harvestable, index)
Client only
Returns the pose weight of the pose in the given index.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| integer | index | The index. |
Returns:
| Type | Description |
|---|---|
| number | The pose weight. |
getPosition(harvestable)
Returns the world coordinates of a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The position. |
getPublicData(harvestable)
Server only
Returns (server) public data from a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| table | The public data. |
getRotation(harvestable)
Returns the quaternion rotation of a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| Quat | The rotation. |
getScale(harvestable)
Returns the scale of the harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The scale. |
getSeatCharacter(kinematic)
Returns the Character that is seated in the kinematic.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | kinematic | The kinematic. |
Returns:
| Type | Description |
|---|---|
| Character | The character. |
getType(harvestable)
Returns the type of a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| string | The harvestable's type. |
getUuid(harvestable)
Returns the Uuid of the harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| Uuid | The uuid. |
getUvFrameIndex(harvestable)
Client only
Returns the index of the current UV animation frame
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| integer | The uv frame. |
getVelocity(harvestable)
Returns the velocity of the harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The velocity. |
getWorld(harvestable)
Returns the world a harvestable exists in.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| World | The world the harvestable exists in. |
hasSeat(kinematic)
Returns true if kinematic has a seat component.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | kinematic | The kinematic. |
Returns:
| Type | Description |
|---|---|
| boolean | The result. |
isCellKinematic(harvestable)
Check if a kinematic comes from a cell or is created from a script.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable to check. |
Returns:
| Type | Description |
|---|---|
| boolean | True if it is a kinematic from a cell, false if it is not. Nil if it is not a kinematic. |
isKinematic(harvestable)
Check if a harvestable is kinematic
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
Returns:
| Type | Description |
|---|---|
| boolean | Return true if the harvestable is kinematic. |
setAllSubMeshVisible(harvestable, visible)
Client only
Set the visibility of all submeshes
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| boolean | visible | True if the submeshes should be visible. |
setClientPublicData(harvestable, data)
Client only
Sets client public data on a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| table | data | The client public data. |
setColor(harvestable, color)
Client only
Sets the color of the harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| Color | color | The color. |
setParams(harvestable, data)
Server only
Sets param data for a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| any | data | The param data. |
setPoseWeight(harvestable, index, value)
Client only
Set the pose weight of the pose in the given index.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| integer | index | The index. |
| number | value | The pose weight. |
setPosition(harvestable, position)
Set the world coordinates of a harvestable. Can only be used on kinematic harvestables.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| Vec3 | position | The position. |
setPublicData(harvestable, data)
Server only
Sets (server) public data on a harvestable.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| table | data | The public data. |
setRotation(harvestable, rotation)
Set the quaternion rotation of a harvestable. Can only be used on kinematic harvestables.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| Quat | rotation | The rotation. |
setSeatCharacter(kinematic, character)
Requests to seat a Character in the kinematic.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | kinematic | The kinematic. |
| Character | character | The character. |
setSubMeshVisible(harvestable, name, visible)
Client only
Set the visibility of a submesh
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| string | name | Name of the submesh. |
| boolean | visible | True if the submesh should be visible. |
setUvFrameIndex(harvestable, index)
Client only
Sets the UV animation frame with the given index.
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| integer | index | The index. |
transformDirection(harvestable, direction)
Transforms a direction in the world into a local direction of the harvestable
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| Vec3 | direction | The world direction. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The local direction. |
transformLocalPoint(harvetable, vector)
Transform a local point to world space.
local worldPos = self.harvestable:transformLocalPoint( localPos )
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvetable | The harvestable. |
| Vec3 | vector | The local point. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The world point. |
transformPoint(harvestable, vector)
Transform a world point to the local harvestable transform.
local localPos = self.harvestable:transformPoint( worldPos )
Parameters:
| Type | Name | Description |
|---|---|---|
| Harvestable | harvestable | The harvestable. |
| Vec3 | vector | The world point. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The local point. |