sm.creation

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

Functions:

  • exportToString
  • exportToTable
  • importFromFile
  • importFromString

  • sm.creation.exportToString(body, exportTransforms=nil, forceDynamic=nil)

    Server only

    Exports creation to blueprint formatted json string.

    Parameters:

    TypeNameDescription
    BodybodyAny body in the creation.
    booleanexportTransforms=nilExport the current world transform of bodies. Defaults to false.
    booleanforceDynamic=nilForce export to dynamic bodies. Defaults to false.

    Returns:

    TypeDescription
    stringThe blueprint json string.

    sm.creation.exportToTable(body, exportTransforms=nil, forceDynamic=nil)

    Server only

    Exports creation to blueprint lua table.

    Parameters:

    TypeNameDescription
    BodybodyAny body in the creation.
    booleanexportTransforms=nilExport the current world transform of bodies. Defaults to false.
    booleanforceDynamic=nilForce export to dynamic bodies. Defaults to false.

    Returns:

    TypeDescription
    tableThe 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:

    TypeNameDescription
    WorldworldThe world to import to.
    stringpathStringThe blueprint path.
    Vec3worldPosition=nilWorld position of import. If importTransforms is enabled position is applied to the imported transform. (Defaults to vec3.zero().)
    QuatworldRotation=nilWorld rotation of import. If importTransforms is enabled rotation is applied to the imported transform. (Defaults to quat.identity().)
    booleanimportTransforms=nilImport world transforms from bodies. (Defaults to false.)
    booleanindestructible=false(DEPRECATED) Ignored, use setDestructable(false) on each body in creation.

    Returns:

    TypeDescription
    tableThe 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:

    TypeNameDescription
    WorldworldThe world to import to.
    stringjsonStringThe blueprint json string.
    Vec3worldPosition=nilWorld position of import. If importTransforms is enabled position is applied to the imported transform. (Defaults to vec3.zero().)
    QuatworldRotation=nilWorld rotation of import. If importTransforms is enabled rotation is applied to the imported transform. (Defaults to quat.identity().)
    booleanimportTransforms=nilImport world transforms from bodies. (Defaults to false.)
    booleanforceInactive=nilImport interactables in an inactive state. (Defaults to false.)

    Returns:

    TypeDescription
    tableThe table {Body, ...} of bodies created from the blueprint.