Lua API

Chara module

Functions for working with characters.

Usage

local Chara = ELONA.require("core.Chara")

Functions

is_alive (chara) Checks if a character is alive.
is_player (chara) Checks if a character is the player.
is_ally (chara) Checks if a character is a member of the player's party.
count () Returns the number of other characters in the current map.
get () Returns the character at the given index.
player () Returns a reference to the player.
create (position) Attempts to create a randomly generated character at a given position.
create (position, id) Attempts to create a character at a given position.
kill_count (id) Obtains the number of times the character type has been killed.
find (id[, location]) Attempts to find a character with the given prototype ID.
can_recruit_allies () Returns true if the player can recruit more allies, taking Charisma into account.
remove_from_party (ally) Removes a character from the player's party, if they are an ally.
all () Returns iterable object containing all characters.
non_allies () Returns iterable object containing characters except for you and your allies.

Functions

# is_alive (chara)

Checks if a character is alive.

Parameters: Returns:
  • (bool) true if the character is alive
# is_player (chara)

Checks if a character is the player.

Parameters: Returns:
  • (bool) true if the character is the player
# is_ally (chara)

Checks if a character is a member of the player's party.

Parameters: Returns:
  • (bool) true if the character is in the player's party
# count ()

Returns the number of other characters in the current map.

# get ()

Returns the character at the given index.

Returns:
Or
# player ()

Returns a reference to the player.

They might not be alive.

Returns:
# create (position)

Attempts to create a randomly generated character at a given position.

Returns the character if creation succeeded, nil otherwise.

Parameters:
  • position : (LuaPosition) (const) position to create the character at
Returns:
Or
# create (position, id)

Attempts to create a character at a given position.

Returns the character if creation succeeded, nil otherwise.

Parameters:
  • position : (LuaPosition) (const) position to create the character at
  • id : (string) the character prototype ID
Returns:
Or
# kill_count (id)

Obtains the number of times the character type has been killed.

Parameters:
  • id : (string) the character prototype ID
# find (id[, location])

Attempts to find a character with the given prototype ID.

Parameters:
  • id : (string) Prototype ID to search
  • location : (CharaFindLocation) Location to search in (defaults to others) (optional)
Returns:
Or
# can_recruit_allies ()

Returns true if the player can recruit more allies, taking Charisma into account.

Returns:
  • (bool)
# remove_from_party (ally)

Removes a character from the player's party, if they are an ally.

Parameters:
# all ()

Returns iterable object containing all characters.

Returns:
  • (table) A sequential table containing all characters.
# non_allies ()

Returns iterable object containing characters except for you and your allies.

Returns:
  • (table) A sequential table containing characters except for you and your allies.