From 7d9f9341752df581877507a3933b204e49b3ad2a Mon Sep 17 00:00:00 2001 From: Robert Zenz Date: Sat, 5 Sep 2015 22:18:50 +0200 Subject: [PATCH] Added provider and callback examples. --- README | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README b/README index 908ad91..c326be1 100644 --- a/README +++ b/README @@ -33,6 +33,53 @@ parameters: Defaults to 0.5 seconds. +Providers +========= + +You can register providers which allow to customize the spawn point of +the players. The provider is a callback that is able to provide a different +spawn point. The signature is: + + function( + player, -- The Player object of the player that is going to respawn. + spawn_pos) -- The current spawn position of the player. + + returns + spawn_pos -- The position at which the player should ge respawned. + -- nil to use the current one. + +And a usage example: + + -- Fixes the spawn point of the player named "hero" at some position. + spawnusher.register_spawnpoint_provider(function(player, spawn_pos) + if player:get_player_name() == "hero" then + return { + x = 0, + y = 125, + z = 50 + } + end + end) + + +After Spawn Callbacks +===================== + +You can register a callback that will be invoked after the player has been +respawned. This callback can't modify the spawn point anymore and is only +to get informed about the actual spawn point of the player. The signature is: + + function( + player, -- The Player object of the player that has respawned. + spawn_point) -- The spawn point of the player. + +Usage example: + + spawnusher.register_after_spawn_callback(function(player, spawn_point) + -- Do something with this information. + end) + + Caveats =======