SpawnpointModule
SpawnpointModule
controls where players are teleported when they first join the game or die and respawn. It uses the SpawnpointProvider
interface to allow games to define their own behavior for setting the spawnpoints of players.
SpawnpointProvider
SpawnpointProvider
is an interface that allows the module to determine where players should spawn.
Public Methods
initialize
Called when the spawnpoint module is loaded by the given game
.
getSpawnpoint
Returns the given player’s spawnpoint. This function is typically called right before a player is going to spawn, and the return value is not cached by SpawnpointModule
between spawns.
getAllSpawnpoints
Returns a list of every place a player could spawn.
Implementations
These implementations are supplied by BlueDragon, but you can always create your own if necessary.
TestSpawnpointProvider
Spawns players sequentially at the positions provided in the constructor.
SingleSpawnpointProvider
Spawns all players at a single location.
ConfigSpawnpointProvider
Gets spawnpoints from the world.spawnpoints
configuration node. If allowRandomOrder
is false
, players will be spawned in the order of the spawnpoints in the config file. Otherwise, players will be spawned in a random order, but no spawnpoint will be used twice until all locations have been used. ConfigModule is required to use this provider.
TeamConfigSpawnpointProvider
Gets spawnpoints from the world.spawnpoints
configuration node. One spawnpoint is assigned to each team. All players on a given team will spawn in the same location. If a player’s spawnpoint is required, and they are not on a team yet, they will be spawned at the first spawnpoint in the database. If they are on a team, they will be given their team’s spawnpoint. If allowRandomOrder
is false
, team spawnpoints will be assigned in the order of the spawnpoints in the config file. Otherwise, teams will be spawned in a random order, but no spawnpoint will be used twice until all locations have been used. ConfigModule and TeamModule are required to use this provider.
Usage
Import the module:
Use the module in your game’s initialize
function:
If you need to get the spawnpoint for a specific player, use the spawnpoint provider: