sm.portal
Associated object type: Portal
A portal moves objects inside a box to another box in another place.
Functions:
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:
| Type | Name | Description |
|---|---|---|
| World | world | The target world. |
| string | name | The portal name. |
| Portal | portal | The portal. |
sm.portal.createPortal(dimensions)
Server only
Creates a new portal.
Parameters:
| Type | Name | Description |
|---|---|---|
| Vec3 | dimensions | The dimensions of the portal box. |
Returns:
| Type | Description |
|---|---|
| Portal | The created portal. |
sm.portal.destroy(portal)
Server only
Destroys a portal.
Parameters:
| Type | Name | Description |
|---|---|---|
| Portal | portal | The portal to be destroyed. |
sm.portal.findBestPortalToWorld(playerWorld, targetWorld, fromPosition)
Finds the portal position that has the best path to the given world.
Parameters:
| Type | Name | Description |
|---|---|---|
| integer | playerWorld | The player's current world id. |
| integer | targetWorld | The world id we wanna get a path towards. |
| Vec3 | fromPosition | 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. |
sm.portal.popWorldPortalHook(name, world?)
Server only
Finds and pops world hook for this world if present.
Parameters:
| Type | Name | Description |
|---|---|---|
| string | name | The portal name. |
| World | world? | The world to look in (Optional, defaults to world from script context) |
Returns:
| Type | Description |
|---|---|
| Portal | The 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:
| Type | Name | Description |
|---|---|---|
| Portal | fromPortal | The portal to transfer from. |
| Portal | toPortal | The portal to transfer to. |
| integer | filter? | 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. |