sm.portal

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

Server + Client

findBestPortalToWorld

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

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

Parameters:

Name Type Description
playerWorld integer The player's current world id.
targetWorld integer The world id we wanna get a path towards.
fromPosition Vec3 The position we wanna get a path from.

Returns:

Type Description
Vec3
Portal
The position of the portal, and the portal with the shortest path to the given world.

Server-only

addWorldPortalHook

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

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

Parameters:

Name Type Description
world World The target world.
name string The portal name.
portal Portal The portal.

createPortal

sm.portal.createPortal( dimensions )

Creates a new portal.

Parameters:

Name Type Description
dimensions Vec3 The dimensions of the portal box.

Returns:

Type Description
Portal The created portal.

destroy

sm.portal.destroy( portal )

Destroys a portal.

Parameters:

Name Type Description
portal Portal The portal to be destroyed.

popWorldPortalHook

sm.portal.popWorldPortalHook( name, world )

Finds and pops world hook for this world if present.

Parameters:

Name Type Description
name string The portal name.
world (optional) World The world to look in (Optional, defaults to world from script context)

Returns:

Type Description
Portal The portal. Nil if nothing was found.

transferBToB

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

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:

Name Type Description
fromPortal Portal The portal to transfer from.
toPortal Portal The portal to transfer to.
filter (optional) integer 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:

Type Description
boolean True if successful, false on failure.