kts.GetPlayer – get the Player corresponding to a Creature
player = kts.GetPlayer(creature)
Given a creature, this first checks if the creature is a knight. If so, a Player object, representing the player in control of that knight, is returned. Otherwise, nil is returned.
A "Player object" is just a Lua userdata object representing the player. It can be used with functions such as kts.GetHomeFor or kts.EliminatePlayer.
Either a Player userdata, or nil is returned.
If the input is not a valid Creature then an error is raised.
If the cxt table is available (this will be the case within "callback" functions, like on_approach, on_walk_over etc), then you can use kts.GetPlayer(cxt.actor) to find the current player (if there is one).
For example, the following code would create a Tile which eliminates from the game any player who walks on it:
function eliminate_player()
local player = kts.GetPlayer(cxt.actor)
if player ~= nil then
print(player, "Ha ha, you stepped on the booby trapped tile, now we are kicking you from the game!!")
kts.EliminatePlayer(player)
end
end
my_tile = kts.Tile{ on_walk_over = eliminate_player,
-- other settings e.g. "graphic", "access"
}
Obviously this would be a very cruel thing to create in an actual game, but it is just an example :)