kts.GetAllHomes – return a list of all "home" (knight entry point) locations in the dungeon
result = kts.GetAllHomes()
This function returns a Lua array/list of all "homes" in the dungeon. A "home" is a Tile which had type="home"
set when it was created; home tiles are where players initially spawn into the dungeon.
Each entry in the array is represented by a Lua table with the following fields:
x
: x-coordinate of the position "in front of" the home (i.e. the square where the knight will be standing when they spawn at this home). y
: y-coordinate of the position "in front of" the home. facing
: facing direction (either "north", "south", "east" or "west"). This is the direction pointing "towards" the home (i.e. out of the dungeon). tile
: a copy of the home Tile itself. secured_by
: this is either a Player object, representing the player who has currently secured this home, or nil
if no player has yet secured the home. (If two or more players secure the same home, then the home is converted to a wall, and then it won't appear in the GetAllHomes
list at all.) The return value is a table as described above. Note that the table might be empty (e.g. this can happen in duel to the death quests, when all entry points have been secured and converted into walls).
None.
Since the "home" tables returned by this function include fields x
and y
, it is valid to pass them to functions that require a "Position" (i.e. the presence of the extra fields facing
, tile
and so on does not stop the tables being valid Positions, since Lua will just ignore the extra fields if they are present).
The list returned by this function includes any "special_exit" points (Guarded Exits) in the dungeon – even though these cannot be used as normal spawn points by knights (they are dungeon exit points only). The tile.special_exit
flag can be used to check for this if required.
An example result might be:
{ { x = 3, y = 4, facing = "west", tile = <tile object> }, { x = 10, y = 13, facing = "south", tile = <tile object> }, { x = 12, y = 9, facing = "east", secured_by = <player object>, tile = <tile object> }, ... }