Skip to main content

sm.creation

A Creation represent a collection of bodies linked together by joints.

Functions

exportToString

sm.creation.exportToString( body, exportTransforms, forceDynamic )
Server-Only

Exports a creation to a blueprint formatted json string.

Arguments:
  • body [ Body ]: Any body in the creation.
  • exportTransforms [ bool ]: Export the current world transform of bodies. Defaults to false.
  • forceDynamic [ bool ]: Force export to dynamic bodies. Defaults to false.
Returns:
  • [ string ]: The blueprint json string.

exportToTable

sm.creation.exportToTable( body, exportTransforms, forceDynamic )
Server-Only

Exports a creation to a blueprint Lua table.

Arguments:
  • body [ Body ]: Any body in the creation.
  • exportTransforms [ bool ]: Export the current world transform of bodies. Defaults to false.
  • forceDynamic [ bool ]: Force export to dynamic bodies. Defaults to false.
Returns:
  • [ table ]: The blueprint Lua table.

importFromFile

sm.creation.importFromFile( world, pathString, worldPosition, worldRotation, importTransforms, indestructible )
Server-Only

Imports a blueprint json file into the world.

If importTransforms is enabled, the world position and rotation are applied to the imported transform.

warning

If the blueprint was not exported with transforms, the importer will treat it as if importTransforms was disabled.

Arguments:
  • world [ World ]: The world to import to.
  • pathString [ string ]: The path to the blueprint file.
  • worldPosition [ Vec3 ]: The world position of the creation. Defaults to sm.vec3.zero()
  • worldRotation [quat ]: The world rotation of the creation. Defaults to sm.quat.identity()
  • importTransforms [ bool ]: Import world transforms from bodies. Defaults to false.
  • indestructible [ bool ]: (DEPRECATED, use setDestructable on each body in the creation.)
Returns:
  • [ table ]: A table of bodies created from the blueprint.

importFromString

sm.creation.importFromString( world, jsonString, worldPosition, worldRotation, importTransforms, forceInactive )
Server-Only

Imports a blueprint json string into the world.

If importTransforms is enabled, the world position and rotation are applied to the imported transform.

warning

If the blueprint was not exported with transforms, the importer will treat it as if importTransforms was disabled.

Arguments:
  • world [ World ]: The world to import to.
  • jsonString [ string ]: The blueprint json string.
  • worldPosition [ Vec3 ]: The world position of the creation. Defaults to sm.vec3.zero()
  • worldRotation [quat ]: The world rotation of the creation. Defaults to sm.quat.identity()
  • importTransforms [ bool ]: Import world transforms from bodies. Defaults to false.
  • forceInactive [ bool ]: Sets whether interactables are forced inactive when imported or not. Defaults to false.
Returns:
  • [ table ]: A table of bodies created from the blueprint.