Module spawnusher

Spawn usher is a system that allows to correct the spawn position of players without knowing anything about the mapgen.

The system will register callbacks for newplayer and respawnplayer and will try to find an air bubble, either upwards or downwards, which the player can fit into. If an air bubble is found, the player will be moved there. If the block is not loaded, it will be tried again after a certain amount of time.

The only function that should be called from clients is activate.

Functions

activate () Activates the spawn usher system, if it has not been deactivated by a seeting in the configuration.
activate_internal () Activates the system, without checking the configuration.
is_air_bubble (start_pos) Tests if the given position is an air bubble big enough.
move_later (player, current_pos) Schedules the player to be moved later.
move_random (player) Moves the player randomly on the x and z plane.
move_player (player) Moves the player to a safe location.
move_players () Move all players that could not be placed so far.
on_spawn_player (player) Callback for if a player spawns.
register_after_spawn_callback (callback) Allows to register callbacks after a player has been spawned by spawn usher.
register_spawnpoint_provider (provider) Allows to register providers that are called after the final position of the player has been determined.

Tables

physics_override The physics override that is set to make the player inmovable.
player_physics The original physics of the payers.

Fields

activate_automatically If the system should be activated automatically.
active If the system is active/has been activated.
after_spawn_callbacks The list of callbacks that are invoked after the player has been placed.
players The list of players that need to be placed.
random_direction If the player should be facing a random direction after spawning.
random_placement_radius The placement radius around the spawn.
required_bubble_size The required air bubble size.
retry_time The retry time.
scheduled If the system is currently scheduled for execution.
spawnpoint The spawnpoint that is configured.
spawnpoint_providers The registered spawnpoint providers.


Functions

activate ()
Activates the spawn usher system, if it has not been deactivated by a seeting in the configuration.
activate_internal ()
Activates the system, without checking the configuration. Multiple invokations have no effect.
is_air_bubble (start_pos)
Tests if the given position is an air bubble big enough.

Parameters:

  • start_pos The position at which to check.

Returns:

    true if at the given position is an air bubble big enough.
move_later (player, current_pos)
Schedules the player to be moved later. Also moves the player to the given position.

Parameters:

  • player The player object.
  • current_pos The current position to which the player will be moved.
move_random (player)
Moves the player randomly on the x and z plane.

Parameters:

  • player The Player object to move.
move_player (player)
Moves the player to a safe location.

Parameters:

  • player The player object.
move_players ()
Move all players that could not be placed so far.
on_spawn_player (player)
Callback for if a player spawns.

Parameters:

  • player The Player that spawned.

Returns:

    true, to disable default placement.
register_after_spawn_callback (callback)
Allows to register callbacks after a player has been spawned by spawn usher.

Parameters:

  • callback The callback to invoke, a function that accepts the player object as first parameter and the spawn point as second.
register_spawnpoint_provider (provider)
Allows to register providers that are called after the final position of the player has been determined. The provider can return a different position, or nil if it is happy with the given position, and if it is is the exact position or not.

Parameters:

  • provider The provider. A function that accepts two parameters, the Player object and the spawn position that the system calculated. It can return a new position, a table with x y z values, or nil if the position should not be changed. The second return value can be true to make the system use the provided position without looking for an air bubble.

Tables

physics_override
The physics override that is set to make the player inmovable.

Fields:

  • speed
  • jump
  • gravity
  • sneak
  • sneak_glitch
player_physics
The original physics of the payers.

Fields

activate_automatically
If the system should be activated automatically.
active
If the system is active/has been activated.
after_spawn_callbacks
The list of callbacks that are invoked after the player has been placed.
players
The list of players that need to be placed.
random_direction
If the player should be facing a random direction after spawning.
random_placement_radius
The placement radius around the spawn.
required_bubble_size
The required air bubble size.
retry_time
The retry time.
scheduled
If the system is currently scheduled for execution.
spawnpoint
The spawnpoint that is configured.
spawnpoint_providers
The registered spawnpoint providers.
generated by LDoc 1.4.2