Updated utils and added callbacks to spawn usher.

master
Robert Zenz 2015-08-15 14:27:33 +02:00
parent cbb05d8da2
commit 218a65a92c
3 changed files with 38 additions and 1 deletions

2
deps/utils vendored

@ -1 +1 @@
Subproject commit 2ae4c72b3d14d74c7b6ac9e919c02164f521b745
Subproject commit 0fdeb22618cd7c2545581c28e32bace4d51a9609

View File

@ -84,6 +84,10 @@
<td class="name" nowrap><a href="#on_spawn_player">on_spawn_player (player)</a></td>
<td class="summary">Callback for if a player spawns.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#register_after_spawn_callback">register_after_spawn_callback (callback)</a></td>
<td class="summary">Allows to register callbacks after a player has been spawned by spawn usher.</td>
</tr>
</table>
<br/>
@ -250,6 +254,27 @@
</dd>
<dt>
<a name = "register_after_spawn_callback"></a>
<strong>register_after_spawn_callback (callback)</strong>
</dt>
<dd>
Allows to register callbacks after a player has been spawned by spawn usher.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">callback</span>
The callback to invoke, a function that accepts the player
object as single parameter.
</li>
</ul>
</dd>
</dl>

View File

@ -36,6 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- The only function that should be called from clients is activate.
spawnusher = {
after_spawn_callbacks = List:new(),
physics_override = {
speed = 0,
jump = 0,
@ -174,6 +175,9 @@ function spawnusher.move_player(player)
-- Remove the saved one.
spawnusher.player_physics[player:get_player_name()] = nil
-- Invoke the callbacks.
spawnusher.after_spawn_callbacks:invoke(player)
return
else
-- The node beneath is neither air nor ignore and there is no
@ -251,3 +255,11 @@ function spawnusher.on_spawn_player(player)
return true
end
--- Allows to register callbacks after a player has been spawned by spawn usher.
--
-- @param callback The callback to invoke, a function that accepts the player
-- object as single parameter.
function spawnusher.register_after_spawn_callback(callback)
spawnusher.after_spawn_callbacks:add(callback)
end