kts.SetRespawnFunction

Name

kts.SetRespawnFunction – set a function to be called whenever a knight respawns

Synopsis

function respawn_func(player)
    -- do stuff...

    -- then either:
    return x, y, direction
    
    -- or:
    return "retry"

    -- or:
    return nil
end

kts.SetRespawnFunction(respawn_func)

Description

Sets a function to be called whenever a knight needs to respawn.

The respawn_func will be called with one parameter which is the Player that needs to respawn. It should return one of the following three possibilities:

Return Value

No value is returned.

Errors

An error results if the passed parameter is neither a valid function nor nil.

Notes

This can only be called during game setup – the respawn function cannot be changed mid-game.

If both SetRespawnType and SetRespawnFunction are used, then the "respawn function" takes priority, and the "respawn type" is only used if the respawn function returned nil.

If the parameter passed to SetRespawnFunction is nil, then any existing respawn function is cleared.

Examples

The Knights Tutorial uses a custom respawn function in order to perform certain actions at respawn time (e.g. turning off the "Chamber of Bats" if it is active) and also to set up custom respawn points depending on the player's progress through the tutorial (i.e. if they die half way through, then they respawn near to where they died, not all the way back at the beginning). This can be seen in tutorial/init.lua (the respawn function itself is here).

See Also

kts.GetRespawnFunction

kts.GetRespawnType

kts.SetRespawnType