The Battle for Wesnoth  1.19.5+dev
Classes | Namespaces | Macros | Enumerations | Functions | Variables
lua_unit.cpp File Reference
#include "scripting/lua_unit.hpp"
#include "formatter.hpp"
#include "game_board.hpp"
#include "log.hpp"
#include "map/location.hpp"
#include "map/map.hpp"
#include "resources.hpp"
#include "scripting/lua_attributes.hpp"
#include "scripting/lua_common.hpp"
#include "scripting/lua_unit_attacks.hpp"
#include "scripting/push_check.hpp"
#include "units/unit.hpp"
#include "units/map.hpp"
#include "units/animation_component.hpp"
#include "utils/optional_fwd.hpp"
#include "game_version.hpp"
#include "deprecation.hpp"
#include <vector>
Include dependency graph for lua_unit.cpp:

Go to the source code of this file.

Classes

struct  lua_object_traits< lua_unit * >
 
struct  lua_object_traits< unit >
 

Namespaces

 lua_units
 

Macros

#define LOG_LUA   LOG_STREAM(info, log_scripting_lua)
 
#define ERR_LUA   LOG_STREAM(err, log_scripting_lua)
 
#define UNIT_GETTER(name, type)   LATTR_GETTER(name, type, unit, u)
 
#define UNIT_SETTER(name, type)   LATTR_SETTER(name, type, unit, u)
 

Enumerations

enum  { LU_OK , LU_NOT_UNIT , LU_NOT_ON_MAP , LU_NOT_VALID }
 

Functions

bool luaW_isunit (lua_State *L, int index)
 Test if a Lua value is a unit. More...
 
static lua_unitinternal_get_unit (lua_State *L, int index, bool only_on_map, int &error)
 
unitluaW_tounit (lua_State *L, int index, bool only_on_map)
 Converts a Lua value to a unit pointer. More...
 
unit_ptr luaW_tounit_ptr (lua_State *L, int index, bool only_on_map)
 Similar to luaW_tounit but returns a unit_ptr; use this instead of luaW_tounit when using an api that needs unit_ptr. More...
 
lua_unitluaW_tounit_ref (lua_State *L, int index)
 Similar to luaW_tounit but returns a lua_unit; use this if you need to handle map and recall units differently, for example. More...
 
static void unit_show_error (lua_State *L, int index, int error)
 
unit_ptr luaW_checkunit_ptr (lua_State *L, int index, bool only_on_map)
 Similar to luaW_checkunit but returns a unit_ptr; use this instead of luaW_checkunit when using an api that needs unit_ptr. More...
 
unitluaW_checkunit (lua_State *L, int index, bool only_on_map)
 Converts a Lua value to a unit pointer. More...
 
lua_unitluaW_checkunit_ref (lua_State *L, int index)
 Similar to luaW_checkunit but returns a lua_unit; use this if you need to handle map and recall units differently, for example. More...
 
lua_unitluaW_pushlocalunit (lua_State *L, unit &u)
 Pushes a private unit on the stack. More...
 
static int impl_unit_collect (lua_State *L)
 Destroys a unit object before it is collected (__gc metamethod). More...
 
static int impl_unit_equality (lua_State *L)
 Checks two lua proxy units for equality. More...
 
static int impl_unit_tostring (lua_State *L)
 Turns a lua proxy unit to string. More...
 
static void handle_unit_move (lua_State *L, lua_unit *lu, map_location dst)
 
 LATTR_GETTER ("valid", utils::optional< std::string >, lua_unit *, lu)
 
 UNIT_GETTER ("x", int)
 
 LATTR_SETTER ("x", int, lua_unit *, lu)
 
 UNIT_GETTER ("y", int)
 
 LATTR_SETTER ("y", int, lua_unit *, lu)
 
 UNIT_GETTER ("loc", map_location)
 
 LATTR_SETTER ("loc", map_location, lua_unit *, lu)
 
 UNIT_GETTER ("goto", map_location)
 
 UNIT_SETTER ("goto", map_location)
 
 UNIT_GETTER ("side", int)
 
 UNIT_SETTER ("side", int)
 
 UNIT_GETTER ("id", std::string)
 
 LATTR_SETTER ("id", std::string, lua_unit *, lu)
 
 UNIT_GETTER ("type", std::string)
 
 UNIT_GETTER ("image_mods", std::string)
 
 UNIT_GETTER ("usage", std::string)
 
 UNIT_SETTER ("usage", std::string)
 
 UNIT_GETTER ("ellipse", std::string)
 
 UNIT_SETTER ("ellipse", std::string)
 
 UNIT_GETTER ("halo", std::string)
 
 UNIT_SETTER ("halo", std::string)
 
 UNIT_GETTER ("hitpoints", int)
 
 UNIT_SETTER ("hitpoints", int)
 
 UNIT_GETTER ("max_hitpoints", int)
 
 UNIT_SETTER ("max_hitpoints", int)
 
 UNIT_GETTER ("experience", int)
 
 UNIT_SETTER ("experience", int)
 
 UNIT_GETTER ("max_experience", int)
 
 UNIT_SETTER ("max_experience", int)
 
 UNIT_GETTER ("recall_cost", int)
 
 UNIT_SETTER ("recall_cost", int)
 
 UNIT_GETTER ("moves", int)
 
 UNIT_SETTER ("moves", int)
 
 UNIT_GETTER ("max_moves", int)
 
 UNIT_SETTER ("max_moves", int)
 
 UNIT_GETTER ("max_attacks", int)
 
 UNIT_SETTER ("max_attacks", int)
 
 UNIT_GETTER ("attacks_left", int)
 
 UNIT_SETTER ("attacks_left", int)
 
 UNIT_GETTER ("vision", int)
 
 UNIT_GETTER ("jamming", int)
 
 UNIT_GETTER ("name", t_string)
 
 UNIT_SETTER ("name", t_string)
 
 UNIT_GETTER ("description", t_string)
 
 UNIT_SETTER ("description", t_string)
 
 UNIT_GETTER ("canrecruit", bool)
 
 UNIT_SETTER ("canrecruit", bool)
 
 UNIT_GETTER ("renamable", bool)
 
 UNIT_SETTER ("renamable", bool)
 
 UNIT_GETTER ("level", int)
 
 UNIT_SETTER ("level", int)
 
 UNIT_GETTER ("cost", int)
 
 UNIT_GETTER ("extra_recruit", std::vector< std::string >)
 
 UNIT_SETTER ("extra_recruit", std::vector< std::string >)
 
 UNIT_GETTER ("advances_to", std::vector< std::string >)
 
 UNIT_SETTER ("advances_to", std::vector< std::string >)
 
 UNIT_GETTER ("alignment", std::string)
 
 UNIT_SETTER ("alignment", lua_index_raw)
 
 UNIT_GETTER ("upkeep", lua_index_raw)
 
 UNIT_SETTER ("upkeep", lua_index_raw)
 
 UNIT_GETTER ("advancements", std::vector< config >)
 
 UNIT_SETTER ("advancements", std::vector< config >)
 
 UNIT_GETTER ("overlays", std::vector< std::string >)
 
 UNIT_GETTER ("traits", std::vector< std::string >)
 
 UNIT_GETTER ("abilities", std::vector< std::string >)
 
 UNIT_GETTER ("status", lua_index_raw)
 
 UNIT_GETTER ("variables", lua_index_raw)
 
 UNIT_GETTER ("attacks", lua_index_raw)
 
 UNIT_GETTER ("petrified", bool)
 
 UNIT_GETTER ("animations", std::vector< std::string >)
 
 UNIT_GETTER ("recall_filter", config)
 
 UNIT_SETTER ("recall_filter", config)
 
 UNIT_GETTER ("hidden", bool)
 
 UNIT_SETTER ("hidden", bool)
 
 UNIT_GETTER ("resting", bool)
 
 UNIT_SETTER ("resting", bool)
 
 UNIT_GETTER ("flying", bool)
 
 UNIT_GETTER ("fearless", bool)
 
 UNIT_GETTER ("healthy", bool)
 
 UNIT_GETTER ("zoc", bool)
 
 UNIT_SETTER ("zoc", bool)
 
 UNIT_GETTER ("role", std::string)
 
 UNIT_SETTER ("role", std::string)
 
 UNIT_GETTER ("race", std::string)
 
 UNIT_GETTER ("gender", std::string)
 
 UNIT_GETTER ("variation", std::string)
 
 UNIT_GETTER ("undead_variation", std::string)
 
 UNIT_SETTER ("undead_variation", std::string)
 
 UNIT_GETTER ("facing", std::string)
 
 UNIT_SETTER ("facing", std::string)
 
 UNIT_GETTER ("portrait", std::string)
 
 UNIT_SETTER ("portrait", std::string)
 
 UNIT_GETTER ("__cfg", config)
 
static int impl_unit_get (lua_State *L)
 Gets some data on a unit (__index metamethod). More...
 
static int impl_unit_set (lua_State *L)
 Sets some data on a unit (__newindex metamethod). More...
 
static int impl_unit_dir (lua_State *L)
 Prints valid attributes on a unit (__dir metamethod). More...
 
static int impl_unit_status_get (lua_State *L)
 Gets the status of a unit (__index metamethod). More...
 
static int impl_unit_status_set (lua_State *L)
 Sets the status of a unit (__newindex metamethod). More...
 
static int impl_unit_status_dir (lua_State *L)
 List statuses on a unit (__dir metamethod) This returns all known statuses (regardless of state) plus any currently set to true. More...
 
static int impl_unit_variables_get (lua_State *L)
 Gets the variable of a unit (__index metamethod). More...
 
static int impl_unit_variables_set (lua_State *L)
 Sets the variable of a unit (__newindex metamethod). More...
 
static int impl_unit_variables_dir (lua_State *L)
 List variables on a unit (__dir metamethod) More...
 
std::string lua_units::register_metatables (lua_State *L)
 

Variables

static lg::log_domain log_scripting_lua ("scripting/lua")
 
static const char getunitKey [] = "unit"
 
static const char ustatusKey [] = "unit status"
 
static const char unitvarKey [] = "unit variables"
 
luaW_Registry unitReg {"wesnoth", "units", getunitKey}
 

Macro Definition Documentation

◆ ERR_LUA

#define ERR_LUA   LOG_STREAM(err, log_scripting_lua)

Definition at line 38 of file lua_unit.cpp.

◆ LOG_LUA

#define LOG_LUA   LOG_STREAM(info, log_scripting_lua)

Definition at line 37 of file lua_unit.cpp.

◆ UNIT_GETTER

#define UNIT_GETTER (   name,
  type 
)    LATTR_GETTER(name, type, unit, u)

Definition at line 274 of file lua_unit.cpp.

◆ UNIT_SETTER

#define UNIT_SETTER (   name,
  type 
)    LATTR_SETTER(name, type, unit, u)

Definition at line 275 of file lua_unit.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LU_OK 
LU_NOT_UNIT 
LU_NOT_ON_MAP 
LU_NOT_VALID 

Definition at line 118 of file lua_unit.cpp.

Function Documentation

◆ handle_unit_move()

static void handle_unit_move ( lua_State *  L,
lua_unit lu,
map_location  dst 
)
static

Definition at line 294 of file lua_unit.cpp.

References dst.

Referenced by LATTR_SETTER().

◆ impl_unit_collect()

static int impl_unit_collect ( lua_State *  L)
static

Destroys a unit object before it is collected (__gc metamethod).

Definition at line 222 of file lua_unit.cpp.

Referenced by lua_units::register_metatables().

◆ impl_unit_dir()

static int impl_unit_dir ( lua_State *  L)
static

Prints valid attributes on a unit (__dir metamethod).

  • Arg 1: full userdata containing the unit id.
  • Arg 2: string containing the name of the property.
  • Ret 1: a list of attributes.

Definition at line 788 of file lua_unit.cpp.

References luaW_Registry::dir(), and unitReg.

Referenced by lua_units::register_metatables().

◆ impl_unit_equality()

static int impl_unit_equality ( lua_State *  L)
static

Checks two lua proxy units for equality.

(__eq metamethod)

Definition at line 232 of file lua_unit.cpp.

References luaW_checkunit(), and unit::underlying_id().

Referenced by lua_units::register_metatables().

◆ impl_unit_get()

static int impl_unit_get ( lua_State *  L)
static

Gets some data on a unit (__index metamethod).

  • Arg 1: full userdata containing the unit id.
  • Arg 2: string containing the name of the property.
  • Ret 1: something containing the attribute.

Definition at line 766 of file lua_unit.cpp.

References luaW_Registry::get(), and unitReg.

Referenced by lua_units::register_metatables().

◆ impl_unit_set()

static int impl_unit_set ( lua_State *  L)
static

Sets some data on a unit (__newindex metamethod).

  • Arg 1: full userdata containing the unit id.
  • Arg 2: string containing the name of the property.
  • Arg 3: something containing the attribute.

Definition at line 777 of file lua_unit.cpp.

References luaW_Registry::set(), and unitReg.

Referenced by lua_units::register_metatables().

◆ impl_unit_status_dir()

static int impl_unit_status_dir ( lua_State *  L)
static

List statuses on a unit (__dir metamethod) This returns all known statuses (regardless of state) plus any currently set to true.

Definition at line 839 of file lua_unit.cpp.

References unit::get_known_boolean_state_name(), unit::get_states(), lua_push(), luaW_tounit(), luaW_type_error(), unit::NUMBER_OF_STATES, s, and unit::STATE_SLOWED.

Referenced by lua_units::register_metatables().

◆ impl_unit_status_get()

static int impl_unit_status_get ( lua_State *  L)
static

Gets the status of a unit (__index metamethod).

  • Arg 1: table containing the userdata containing the unit id.
  • Arg 2: string containing the name of the status.
  • Ret 1: boolean.

Definition at line 799 of file lua_unit.cpp.

References unit::get_state(), luaW_tounit(), and luaW_type_error().

Referenced by lua_units::register_metatables().

◆ impl_unit_status_set()

static int impl_unit_status_set ( lua_State *  L)
static

Sets the status of a unit (__newindex metamethod).

  • Arg 1: table containing the userdata containing the unit id.
  • Arg 2: string containing the name of the status.
  • Arg 3: boolean.

Definition at line 820 of file lua_unit.cpp.

References luaW_toboolean(), luaW_tounit(), luaW_type_error(), and unit::set_state().

Referenced by lua_units::register_metatables().

◆ impl_unit_tostring()

static int impl_unit_tostring ( lua_State *  L)
static

Turns a lua proxy unit to string.

(__tostring metamethod)

Definition at line 244 of file lua_unit.cpp.

References unit::get_location(), unit::id(), luaW_tounit_ref(), and unit::type_id().

Referenced by lua_units::register_metatables().

◆ impl_unit_variables_dir()

static int impl_unit_variables_dir ( lua_State *  L)
static

◆ impl_unit_variables_get()

static int impl_unit_variables_get ( lua_State *  L)
static

Gets the variable of a unit (__index metamethod).

  • Arg 1: table containing the userdata containing the unit id.
  • Arg 2: string containing the name of the status.
  • Ret 1: boolean.

Definition at line 867 of file lua_unit.cpp.

References luaW_pushvariable(), luaW_tounit(), luaW_type_error(), return_cfgref_attrib, and unit::variables().

Referenced by lua_units::register_metatables().

◆ impl_unit_variables_set()

static int impl_unit_variables_set ( lua_State *  L)
static

Sets the variable of a unit (__newindex metamethod).

  • Arg 1: table containing the userdata containing the unit id.
  • Arg 2: string containing the name of the status.
  • Arg 3: scalar.

Definition at line 890 of file lua_unit.cpp.

References luaW_checkvariable(), luaW_tounit(), luaW_type_error(), modify_cfg_attrib, and unit::variables().

Referenced by lua_units::register_metatables().

◆ internal_get_unit()

static lua_unit* internal_get_unit ( lua_State *  L,
int  index,
bool  only_on_map,
int &  error 
)
static

◆ LATTR_GETTER()

LATTR_GETTER ( "valid"  ,
utils::optional< std::string >  ,
lua_unit ,
lu   
)

Definition at line 326 of file lua_unit.cpp.

References s.

◆ LATTR_SETTER() [1/4]

LATTR_SETTER ( "id"  ,
std::string  ,
lua_unit ,
lu   
)

Definition at line 391 of file lua_unit.cpp.

◆ LATTR_SETTER() [2/4]

LATTR_SETTER ( "loc"  ,
map_location  ,
lua_unit ,
lu   
)

Definition at line 366 of file lua_unit.cpp.

References handle_unit_move().

◆ LATTR_SETTER() [3/4]

LATTR_SETTER ( "x"  ,
int  ,
lua_unit ,
lu   
)

Definition at line 344 of file lua_unit.cpp.

References handle_unit_move(), and map_location::set_wml_x().

◆ LATTR_SETTER() [4/4]

LATTR_SETTER ( "y"  ,
int  ,
lua_unit ,
lu   
)

Definition at line 355 of file lua_unit.cpp.

References handle_unit_move(), and map_location::set_wml_y().

◆ luaW_checkunit()

unit& luaW_checkunit ( lua_State *  L,
int  index,
bool  only_on_map 
)

◆ luaW_checkunit_ptr()

unit_ptr luaW_checkunit_ptr ( lua_State *  L,
int  index,
bool  only_on_map 
)

Similar to luaW_checkunit but returns a unit_ptr; use this instead of luaW_checkunit when using an api that needs unit_ptr.

Definition at line 183 of file lua_unit.cpp.

References utf8::index(), internal_get_unit(), and unit_show_error().

Referenced by impl_add_animation(), game_lua_kernel::intf_find_vacant_tile(), and game_lua_kernel::intf_teleport().

◆ luaW_checkunit_ref()

lua_unit* luaW_checkunit_ref ( lua_State *  L,
int  index 
)

Similar to luaW_checkunit but returns a lua_unit; use this if you need to handle map and recall units differently, for example.

Definition at line 199 of file lua_unit.cpp.

References utf8::index(), internal_get_unit(), and unit_show_error().

Referenced by game_lua_kernel::intf_erase_unit(), game_lua_kernel::intf_extract_unit(), game_lua_kernel::intf_match_unit(), game_lua_kernel::intf_put_recall_unit(), and game_lua_kernel::intf_put_unit().

◆ luaW_isunit()

bool luaW_isunit ( lua_State *  L,
int  index 
)

◆ luaW_pushlocalunit()

lua_unit* luaW_pushlocalunit ( lua_State *  L,
unit u 
)

Pushes a private unit on the stack.

Definition at line 212 of file lua_unit.cpp.

Referenced by game_lua_kernel::apply_effect(), and game_lua_kernel::run_filter().

◆ luaW_tounit()

unit* luaW_tounit ( lua_State *  L,
int  index,
bool  only_on_map 
)

◆ luaW_tounit_ptr()

unit_ptr luaW_tounit_ptr ( lua_State *  L,
int  index,
bool  only_on_map 
)

Similar to luaW_tounit but returns a unit_ptr; use this instead of luaW_tounit when using an api that needs unit_ptr.

Definition at line 152 of file lua_unit.cpp.

References utf8::index(), internal_get_unit(), and LU_OK.

◆ luaW_tounit_ref()

lua_unit* luaW_tounit_ref ( lua_State *  L,
int  index 
)

Similar to luaW_tounit but returns a lua_unit; use this if you need to handle map and recall units differently, for example.

Note that this only returns null if the element on the stack was not a unit, so it may be an invalid unit.

Definition at line 162 of file lua_unit.cpp.

References utf8::index(), and internal_get_unit().

Referenced by impl_unit_attacks_get(), and impl_unit_tostring().

◆ UNIT_GETTER() [1/56]

UNIT_GETTER ( "__cfg"  ,
config   
)

Definition at line 753 of file lua_unit.cpp.

References unit::get_location(), map_location::write(), and unit::write().

◆ UNIT_GETTER() [2/56]

UNIT_GETTER ( "abilities"  ,
std::vector< std::string >   
)

Definition at line 626 of file lua_unit.cpp.

References unit::get_ability_list().

◆ UNIT_GETTER() [3/56]

UNIT_GETTER ( "advancements"  ,
std::vector< config  
)

Definition at line 610 of file lua_unit.cpp.

References unit::modification_advancements().

◆ UNIT_GETTER() [4/56]

UNIT_GETTER ( "advances_to"  ,
std::vector< std::string >   
)

Definition at line 561 of file lua_unit.cpp.

References unit::advances_to().

◆ UNIT_GETTER() [5/56]

UNIT_GETTER ( "alignment"  ,
std::string   
)

◆ UNIT_GETTER() [6/56]

UNIT_GETTER ( "animations"  ,
std::vector< std::string >   
)

Definition at line 659 of file lua_unit.cpp.

References unit::anim_comp(), and unit_animation_component::get_flags().

◆ UNIT_GETTER() [7/56]

UNIT_GETTER ( "attacks"  ,
lua_index_raw   
)

Definition at line 648 of file lua_unit.cpp.

References push_unit_attacks_table().

◆ UNIT_GETTER() [8/56]

UNIT_GETTER ( "attacks_left"  ,
int   
)

Definition at line 493 of file lua_unit.cpp.

References unit::attacks_left().

◆ UNIT_GETTER() [9/56]

UNIT_GETTER ( "canrecruit"  ,
bool   
)

Definition at line 525 of file lua_unit.cpp.

References unit::can_recruit().

◆ UNIT_GETTER() [10/56]

UNIT_GETTER ( "cost"  ,
int   
)

Definition at line 549 of file lua_unit.cpp.

References unit::cost().

◆ UNIT_GETTER() [11/56]

UNIT_GETTER ( "description"  ,
t_string   
)

Definition at line 517 of file lua_unit.cpp.

References unit::unit_description().

◆ UNIT_GETTER() [12/56]

UNIT_GETTER ( "ellipse"  ,
std::string   
)

Definition at line 413 of file lua_unit.cpp.

References unit::image_ellipse().

◆ UNIT_GETTER() [13/56]

UNIT_GETTER ( "experience"  ,
int   
)

Definition at line 445 of file lua_unit.cpp.

References unit::experience().

◆ UNIT_GETTER() [14/56]

UNIT_GETTER ( "extra_recruit"  ,
std::vector< std::string >   
)

Definition at line 553 of file lua_unit.cpp.

References unit::recruits().

◆ UNIT_GETTER() [15/56]

UNIT_GETTER ( "facing"  ,
std::string   
)

Definition at line 735 of file lua_unit.cpp.

References unit::facing(), and map_location::write_direction().

◆ UNIT_GETTER() [16/56]

UNIT_GETTER ( "fearless"  ,
bool   
)

Definition at line 691 of file lua_unit.cpp.

References unit::is_fearless().

◆ UNIT_GETTER() [17/56]

UNIT_GETTER ( "flying"  ,
bool   
)

Definition at line 687 of file lua_unit.cpp.

References unit::is_flying().

◆ UNIT_GETTER() [18/56]

UNIT_GETTER ( "gender"  ,
std::string   
)

Definition at line 719 of file lua_unit.cpp.

References unit::gender(), and gender_string().

◆ UNIT_GETTER() [19/56]

UNIT_GETTER ( "goto"  ,
map_location   
)

Definition at line 371 of file lua_unit.cpp.

References unit::get_goto().

◆ UNIT_GETTER() [20/56]

UNIT_GETTER ( "halo"  ,
std::string   
)

Definition at line 421 of file lua_unit.cpp.

References unit::image_halo().

◆ UNIT_GETTER() [21/56]

UNIT_GETTER ( "healthy"  ,
bool   
)

Definition at line 695 of file lua_unit.cpp.

References unit::is_healthy().

◆ UNIT_GETTER() [22/56]

UNIT_GETTER ( "hidden"  ,
bool   
)

Definition at line 671 of file lua_unit.cpp.

References unit::get_hidden().

◆ UNIT_GETTER() [23/56]

UNIT_GETTER ( "hitpoints"  ,
int   
)

Definition at line 429 of file lua_unit.cpp.

References unit::hitpoints().

◆ UNIT_GETTER() [24/56]

UNIT_GETTER ( "id"  ,
std::string   
)

Definition at line 387 of file lua_unit.cpp.

References unit::id().

◆ UNIT_GETTER() [25/56]

UNIT_GETTER ( "image_mods"  ,
std::string   
)

Definition at line 401 of file lua_unit.cpp.

References unit::effect_image_mods().

◆ UNIT_GETTER() [26/56]

UNIT_GETTER ( "jamming"  ,
int   
)

Definition at line 505 of file lua_unit.cpp.

References unit::jamming().

◆ UNIT_GETTER() [27/56]

UNIT_GETTER ( "level"  ,
int   
)

Definition at line 541 of file lua_unit.cpp.

References unit::level().

◆ UNIT_GETTER() [28/56]

UNIT_GETTER ( "loc"  ,
map_location   
)

Definition at line 362 of file lua_unit.cpp.

References unit::get_location().

◆ UNIT_GETTER() [29/56]

UNIT_GETTER ( "max_attacks"  ,
int   
)

Definition at line 485 of file lua_unit.cpp.

References unit::max_attacks().

◆ UNIT_GETTER() [30/56]

UNIT_GETTER ( "max_experience"  ,
int   
)

Definition at line 453 of file lua_unit.cpp.

References unit::max_experience().

◆ UNIT_GETTER() [31/56]

UNIT_GETTER ( "max_hitpoints"  ,
int   
)

Definition at line 437 of file lua_unit.cpp.

References unit::max_hitpoints().

◆ UNIT_GETTER() [32/56]

UNIT_GETTER ( "max_moves"  ,
int   
)

Definition at line 477 of file lua_unit.cpp.

References unit::total_movement().

◆ UNIT_GETTER() [33/56]

UNIT_GETTER ( "moves"  ,
int   
)

Definition at line 469 of file lua_unit.cpp.

References unit::movement_left().

◆ UNIT_GETTER() [34/56]

UNIT_GETTER ( "name"  ,
t_string   
)

Definition at line 509 of file lua_unit.cpp.

References unit::name().

◆ UNIT_GETTER() [35/56]

UNIT_GETTER ( "overlays"  ,
std::vector< std::string >   
)

Definition at line 618 of file lua_unit.cpp.

References unit::overlays().

◆ UNIT_GETTER() [36/56]

UNIT_GETTER ( "petrified"  ,
bool   
)

Definition at line 654 of file lua_unit.cpp.

References deprecated_message(), unit::incapacitated(), and INDEFINITE.

◆ UNIT_GETTER() [37/56]

UNIT_GETTER ( "portrait"  ,
std::string   
)

Definition at line 743 of file lua_unit.cpp.

References unit::absolute_image(), unit::big_profile(), and unit::image_mods().

◆ UNIT_GETTER() [38/56]

UNIT_GETTER ( "race"  ,
std::string   
)

Definition at line 715 of file lua_unit.cpp.

References unit_race::id(), and unit::race().

◆ UNIT_GETTER() [39/56]

UNIT_GETTER ( "recall_cost"  ,
int   
)

Definition at line 461 of file lua_unit.cpp.

References unit::recall_cost().

◆ UNIT_GETTER() [40/56]

UNIT_GETTER ( "recall_filter"  ,
config   
)

Definition at line 663 of file lua_unit.cpp.

References unit::recall_filter().

◆ UNIT_GETTER() [41/56]

UNIT_GETTER ( "renamable"  ,
bool   
)

Definition at line 533 of file lua_unit.cpp.

References unit::unrenamable().

◆ UNIT_GETTER() [42/56]

UNIT_GETTER ( "resting"  ,
bool   
)

Definition at line 679 of file lua_unit.cpp.

References unit::resting().

◆ UNIT_GETTER() [43/56]

UNIT_GETTER ( "role"  ,
std::string   
)

Definition at line 707 of file lua_unit.cpp.

References unit::get_role().

◆ UNIT_GETTER() [44/56]

UNIT_GETTER ( "side"  ,
int   
)

Definition at line 379 of file lua_unit.cpp.

References unit::side().

◆ UNIT_GETTER() [45/56]

UNIT_GETTER ( "status"  ,
lua_index_raw   
)

Definition at line 630 of file lua_unit.cpp.

References ustatusKey.

◆ UNIT_GETTER() [46/56]

UNIT_GETTER ( "traits"  ,
std::vector< std::string >   
)

Definition at line 622 of file lua_unit.cpp.

References unit::get_traits_list().

◆ UNIT_GETTER() [47/56]

UNIT_GETTER ( "type"  ,
std::string   
)

Definition at line 397 of file lua_unit.cpp.

References unit::type_id().

◆ UNIT_GETTER() [48/56]

UNIT_GETTER ( "undead_variation"  ,
std::string   
)

Definition at line 727 of file lua_unit.cpp.

References unit::undead_variation().

◆ UNIT_GETTER() [49/56]

UNIT_GETTER ( "upkeep"  ,
lua_index_raw   
)

Definition at line 579 of file lua_unit.cpp.

References lua_push(), and unit::upkeep_raw().

◆ UNIT_GETTER() [50/56]

UNIT_GETTER ( "usage"  ,
std::string   
)

Definition at line 405 of file lua_unit.cpp.

References unit::usage().

◆ UNIT_GETTER() [51/56]

UNIT_GETTER ( "variables"  ,
lua_index_raw   
)

Definition at line 639 of file lua_unit.cpp.

References unitvarKey.

◆ UNIT_GETTER() [52/56]

UNIT_GETTER ( "variation"  ,
std::string   
)

Definition at line 723 of file lua_unit.cpp.

References unit::variation().

◆ UNIT_GETTER() [53/56]

UNIT_GETTER ( "vision"  ,
int   
)

Definition at line 501 of file lua_unit.cpp.

References unit::vision().

◆ UNIT_GETTER() [54/56]

UNIT_GETTER ( "x"  ,
int   
)

Definition at line 340 of file lua_unit.cpp.

References unit::get_location(), and map_location::wml_x().

◆ UNIT_GETTER() [55/56]

UNIT_GETTER ( "y"  ,
int   
)

Definition at line 351 of file lua_unit.cpp.

References unit::get_location(), and map_location::wml_y().

◆ UNIT_GETTER() [56/56]

UNIT_GETTER ( "zoc"  ,
bool   
)

Definition at line 699 of file lua_unit.cpp.

References unit::get_emit_zoc().

◆ UNIT_SETTER() [1/32]

UNIT_SETTER ( "advancements"  ,
std::vector< config  
)

Definition at line 614 of file lua_unit.cpp.

References unit::set_advancements().

◆ UNIT_SETTER() [2/32]

UNIT_SETTER ( "advances_to"  ,
std::vector< std::string >   
)

Definition at line 565 of file lua_unit.cpp.

References unit::set_advances_to().

◆ UNIT_SETTER() [3/32]

UNIT_SETTER ( "alignment"  ,
lua_index_raw   
)

◆ UNIT_SETTER() [4/32]

UNIT_SETTER ( "attacks_left"  ,
int   
)

Definition at line 497 of file lua_unit.cpp.

References unit::set_attacks().

◆ UNIT_SETTER() [5/32]

UNIT_SETTER ( "canrecruit"  ,
bool   
)

Definition at line 529 of file lua_unit.cpp.

References unit::set_can_recruit().

◆ UNIT_SETTER() [6/32]

UNIT_SETTER ( "description"  ,
t_string   
)

Definition at line 521 of file lua_unit.cpp.

References unit::set_unit_description().

◆ UNIT_SETTER() [7/32]

UNIT_SETTER ( "ellipse"  ,
std::string   
)

Definition at line 417 of file lua_unit.cpp.

References unit::set_image_ellipse().

◆ UNIT_SETTER() [8/32]

UNIT_SETTER ( "experience"  ,
int   
)

Definition at line 449 of file lua_unit.cpp.

References unit::set_experience().

◆ UNIT_SETTER() [9/32]

UNIT_SETTER ( "extra_recruit"  ,
std::vector< std::string >   
)

Definition at line 557 of file lua_unit.cpp.

References unit::set_recruits().

◆ UNIT_SETTER() [10/32]

UNIT_SETTER ( "facing"  ,
std::string   
)

Definition at line 739 of file lua_unit.cpp.

References map_location::parse_direction(), and unit::set_facing().

◆ UNIT_SETTER() [11/32]

UNIT_SETTER ( "goto"  ,
map_location   
)

Definition at line 375 of file lua_unit.cpp.

References unit::set_goto().

◆ UNIT_SETTER() [12/32]

UNIT_SETTER ( "halo"  ,
std::string   
)

Definition at line 425 of file lua_unit.cpp.

References unit::set_image_halo().

◆ UNIT_SETTER() [13/32]

UNIT_SETTER ( "hidden"  ,
bool   
)

Definition at line 675 of file lua_unit.cpp.

References unit::set_hidden().

◆ UNIT_SETTER() [14/32]

UNIT_SETTER ( "hitpoints"  ,
int   
)

Definition at line 433 of file lua_unit.cpp.

References unit::set_hitpoints().

◆ UNIT_SETTER() [15/32]

UNIT_SETTER ( "level"  ,
int   
)

Definition at line 545 of file lua_unit.cpp.

References unit::set_level().

◆ UNIT_SETTER() [16/32]

UNIT_SETTER ( "max_attacks"  ,
int   
)

Definition at line 489 of file lua_unit.cpp.

References unit::set_max_attacks().

◆ UNIT_SETTER() [17/32]

UNIT_SETTER ( "max_experience"  ,
int   
)

Definition at line 457 of file lua_unit.cpp.

References unit::set_max_experience().

◆ UNIT_SETTER() [18/32]

UNIT_SETTER ( "max_hitpoints"  ,
int   
)

Definition at line 441 of file lua_unit.cpp.

References unit::set_max_hitpoints().

◆ UNIT_SETTER() [19/32]

UNIT_SETTER ( "max_moves"  ,
int   
)

Definition at line 481 of file lua_unit.cpp.

References unit::set_total_movement().

◆ UNIT_SETTER() [20/32]

UNIT_SETTER ( "moves"  ,
int   
)

Definition at line 473 of file lua_unit.cpp.

References unit::set_movement().

◆ UNIT_SETTER() [21/32]

UNIT_SETTER ( "name"  ,
t_string   
)

Definition at line 513 of file lua_unit.cpp.

References unit::set_name().

◆ UNIT_SETTER() [22/32]

UNIT_SETTER ( "portrait"  ,
std::string   
)

Definition at line 749 of file lua_unit.cpp.

References unit::set_big_profile().

◆ UNIT_SETTER() [23/32]

UNIT_SETTER ( "recall_cost"  ,
int   
)

Definition at line 465 of file lua_unit.cpp.

References unit::set_recall_cost().

◆ UNIT_SETTER() [24/32]

UNIT_SETTER ( "recall_filter"  ,
config   
)

Definition at line 667 of file lua_unit.cpp.

References unit::set_recall_filter().

◆ UNIT_SETTER() [25/32]

UNIT_SETTER ( "renamable"  ,
bool   
)

Definition at line 537 of file lua_unit.cpp.

References unit::set_unrenamable().

◆ UNIT_SETTER() [26/32]

UNIT_SETTER ( "resting"  ,
bool   
)

Definition at line 683 of file lua_unit.cpp.

References unit::set_resting().

◆ UNIT_SETTER() [27/32]

UNIT_SETTER ( "role"  ,
std::string   
)

Definition at line 711 of file lua_unit.cpp.

References unit::set_role().

◆ UNIT_SETTER() [28/32]

UNIT_SETTER ( "side"  ,
int   
)

Definition at line 383 of file lua_unit.cpp.

References unit::set_side().

◆ UNIT_SETTER() [29/32]

UNIT_SETTER ( "undead_variation"  ,
std::string   
)

Definition at line 731 of file lua_unit.cpp.

References unit::set_undead_variation().

◆ UNIT_SETTER() [30/32]

UNIT_SETTER ( "upkeep"  ,
lua_index_raw   
)

Definition at line 592 of file lua_unit.cpp.

References unit::set_upkeep().

◆ UNIT_SETTER() [31/32]

UNIT_SETTER ( "usage"  ,
std::string   
)

Definition at line 409 of file lua_unit.cpp.

References unit::set_usage().

◆ UNIT_SETTER() [32/32]

UNIT_SETTER ( "zoc"  ,
bool   
)

Definition at line 703 of file lua_unit.cpp.

References unit::set_emit_zoc().

◆ unit_show_error()

static void unit_show_error ( lua_State *  L,
int  index,
int  error 
)
static

Variable Documentation

◆ getunitKey

const char getunitKey[] = "unit"
static

◆ log_scripting_lua

lg::log_domain log_scripting_lua("scripting/lua") ( "scripting/lua"  )
static

◆ unitReg

luaW_Registry unitReg {"wesnoth", "units", getunitKey}

Definition at line 276 of file lua_unit.cpp.

Referenced by impl_unit_dir(), impl_unit_get(), and impl_unit_set().

◆ unitvarKey

const char unitvarKey[] = "unit variables"
static

Definition at line 42 of file lua_unit.cpp.

Referenced by lua_units::register_metatables(), and UNIT_GETTER().

◆ ustatusKey

const char ustatusKey[] = "unit status"
static

Definition at line 41 of file lua_unit.cpp.

Referenced by lua_units::register_metatables(), and UNIT_GETTER().