sm.portal

Associated object type: Portal

A portal moves objects inside a box to another box in another place.

Functions:

  • addWorldPortalHook
  • createPortal
  • destroy
  • findBestPortalToWorld
  • popWorldPortalHook
  • transferBToB

  • sm.portal.addWorldPortalHook(world, name, portal)

    Server only

    Adds a hook that a new world can find to hook up the other side of a portal.

    Parameters:

    TypeNameDescription
    WorldworldThe target world.
    stringnameThe portal name.
    PortalportalThe portal.

    sm.portal.createPortal(dimensions)

    Server only

    Creates a new portal.

    Parameters:

    TypeNameDescription
    Vec3dimensionsThe dimensions of the portal box.

    Returns:

    TypeDescription
    PortalThe created portal.

    sm.portal.destroy(portal)

    Server only

    Destroys a portal.

    Parameters:

    TypeNameDescription
    PortalportalThe portal to be destroyed.

    sm.portal.findBestPortalToWorld(playerWorld, targetWorld, fromPosition)

    Finds the portal position that has the best path to the given world.

    Parameters:

    TypeNameDescription
    integerplayerWorldThe player's current world id.
    integertargetWorldThe world id we wanna get a path towards.
    Vec3fromPositionThe position we wanna get a path from.

    Returns:

    TypeDescription
    Vec3, PortalThe position of the portal, and the portal with the shortest path to the given world.

    sm.portal.popWorldPortalHook(name, world?)

    Server only

    Finds and pops world hook for this world if present.

    Parameters:

    TypeNameDescription
    stringnameThe portal name.
    Worldworld?The world to look in (Optional, defaults to world from script context)

    Returns:

    TypeDescription
    PortalThe portal. Nil if nothing was found.

    sm.portal.transferBToB(fromPortal, toPortal, filter?)

    Server only

    Transfers objects inside one B opening to the B opening of another portal.

    Can be used to make elevators with several floors.

    Portal sizes and opening A must match (world, position and rotation).

    Parameters:

    TypeNameDescription
    PortalfromPortalThe portal to transfer from.
    PortaltoPortalThe portal to transfer to.
    integerfilter?A sm.physics.filter mask selecting which contents to transfer. Only dynamicBody, staticBody and character are meaningful. Defaults to transferring bodies and characters. (Optional)

    Returns:

    TypeDescription
    booleanTrue if successful, false on failure.