sm.creation
A Creation represent a collection of bodies linked together by joints.
Functions:
sm.creation.exportToString(body, exportTransforms=nil, forceDynamic=nil)
Server only
Exports creation to blueprint formatted json string.
Parameters:
| Type | Name | Description |
|---|---|---|
| Body | body | Any body in the creation. |
| boolean | exportTransforms=nil | Export the current world transform of bodies. Defaults to false. |
| boolean | forceDynamic=nil | Force export to dynamic bodies. Defaults to false. |
Returns:
| Type | Description |
|---|---|
| string | The blueprint json string. |
sm.creation.exportToTable(body, exportTransforms=nil, forceDynamic=nil)
Server only
Exports creation to blueprint lua table.
Parameters:
| Type | Name | Description |
|---|---|---|
| Body | body | Any body in the creation. |
| boolean | exportTransforms=nil | Export the current world transform of bodies. Defaults to false. |
| boolean | forceDynamic=nil | Force export to dynamic bodies. Defaults to false. |
Returns:
| Type | Description |
|---|---|
| table | The blueprint lua table. |
sm.creation.importFromFile(world, pathString, worldPosition=nil, worldRotation=nil, importTransforms=nil, indestructible=false)
Server only
Imports blueprint json file to world.
Warning:
If the blueprint was not exported with transforms the importer will treat it as if importTransforms was disabled.
Parameters:
| Type | Name | Description |
|---|---|---|
| World | world | The world to import to. |
| string | pathString | The blueprint path. |
| Vec3 | worldPosition=nil | World position of import. If importTransforms is enabled position is applied to the imported transform. (Defaults to vec3.zero().) |
| Quat | worldRotation=nil | World rotation of import. If importTransforms is enabled rotation is applied to the imported transform. (Defaults to quat.identity().) |
| boolean | importTransforms=nil | Import world transforms from bodies. (Defaults to false.) |
| boolean | indestructible=false | (DEPRECATED) Ignored, use setDestructable(false) on each body in creation. |
Returns:
| Type | Description |
|---|---|
| table | The table {Body, ...} of bodies created from the blueprint. |
sm.creation.importFromString(world, jsonString, worldPosition=nil, worldRotation=nil, importTransforms=nil, forceInactive=nil)
Server only
Imports blueprint json string to world.
Warning:
If the blueprint was not exported with transforms the importer will treat it as if importTransforms was disabled.
Parameters:
| Type | Name | Description |
|---|---|---|
| World | world | The world to import to. |
| string | jsonString | The blueprint json string. |
| Vec3 | worldPosition=nil | World position of import. If importTransforms is enabled position is applied to the imported transform. (Defaults to vec3.zero().) |
| Quat | worldRotation=nil | World rotation of import. If importTransforms is enabled rotation is applied to the imported transform. (Defaults to quat.identity().) |
| boolean | importTransforms=nil | Import world transforms from bodies. (Defaults to false.) |
| boolean | forceInactive=nil | Import interactables in an inactive state. (Defaults to false.) |
Returns:
| Type | Description |
|---|---|
| table | The table {Body, ...} of bodies created from the blueprint. |