The Battle for Wesnoth  1.19.0-dev
Namespaces | Functions | Variables
lua_team.cpp File Reference
#include "scripting/lua_team.hpp"
#include "scripting/lua_common.hpp"
#include "scripting/push_check.hpp"
#include "scripting/game_lua_kernel.hpp"
#include "team.hpp"
#include "resources.hpp"
#include "game_board.hpp"
#include "game_display.hpp"
#include "map/map.hpp"
#include <string>
Include dependency graph for lua_team.cpp:

Go to the source code of this file.

Namespaces

 lua_team
 This namespace contains bindings for lua to hold a pointer to a team, and to access and modify it.
 

Functions

static int impl_side_get (lua_State *L)
 Gets some data on a side (__index metamethod). More...
 
static int impl_side_tostring (lua_State *L)
 Turns a lua proxy side to string. More...
 
static int impl_side_set (lua_State *L)
 Sets some data on a side (__newindex metamethod). More...
 
static int impl_side_equal (lua_State *L)
 
static int impl_side_variables_get (lua_State *L)
 Gets the variable of a side (__index metamethod). More...
 
static int impl_side_variables_set (lua_State *L)
 Sets the variable of a side (__newindex metamethod). More...
 
std::string lua_team::register_metatable (lua_State *L)
 
void luaW_pushteam (lua_State *L, team &tm)
 Create a full userdata containing a pointer to the team. More...
 
teamluaW_checkteam (lua_State *L, int idx)
 Test if the top stack element is a team, and if not, error. More...
 
teamluaW_checkteam (lua_State *L, int idx, game_board &board)
 Get a team either from a direct userdata or from a side number. More...
 
teamluaW_toteam (lua_State *L, int idx)
 Test if the top stack element is a team, and if so, return it. More...
 

Variables

static const char * Team = "side"
 Implementation for a lua reference to a team, used by the wesnoth in-game sides table. More...
 
static const char teamVar [] = "side variables"
 

Function Documentation

◆ impl_side_equal()

static int impl_side_equal ( lua_State *  L)
static

Definition at line 238 of file lua_team.cpp.

◆ impl_side_get()

static int impl_side_get ( lua_State *  L)
static

Gets some data on a side (__index metamethod).

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

Definition at line 52 of file lua_team.cpp.

References d, game_config::images::flag, game_config::images::flag_icon, resources::gameboard, string_enums::enum_base< Definition >::get_string(), i, luaW_checkteam(), luaW_getglobal(), luaW_pushlocation(), game_board::map(), return_bool_attrib, return_cfg_attrib, return_float_attrib, return_int_attrib, return_string_attrib, return_tstring_attrib, gamemap_base::starting_position(), t, and teamVar.

◆ impl_side_set()

static int impl_side_set ( lua_State *  L)
static

Sets some data on a side (__newindex metamethod).

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

Definition at line 161 of file lua_team.cpp.

◆ impl_side_tostring()

static int impl_side_tostring ( lua_State *  L)
static

Turns a lua proxy side to string.

(__tostring metamethod)

Definition at line 140 of file lua_team.cpp.

References luaW_checkteam(), team::side(), and team::side_name().

◆ impl_side_variables_get()

static int impl_side_variables_get ( lua_State *  L)
static

Gets the variable of a side (__index metamethod).

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

Definition at line 256 of file lua_team.cpp.

◆ impl_side_variables_set()

static int impl_side_variables_set ( lua_State *  L)
static

Sets the variable of a side (__newindex metamethod).

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

Definition at line 277 of file lua_team.cpp.

◆ luaW_checkteam() [1/2]

team& luaW_checkteam ( lua_State *  L,
int  idx 
)

◆ luaW_checkteam() [2/2]

team& luaW_checkteam ( lua_State *  L,
int  idx,
game_board board 
)

Get a team either from a direct userdata or from a side number.

Definition at line 352 of file lua_team.cpp.

◆ luaW_pushteam()

void luaW_pushteam ( lua_State *  L,
team tm 
)

Create a full userdata containing a pointer to the team.

Definition at line 340 of file lua_team.cpp.

Referenced by game_lua_kernel::intf_get_side(), game_lua_kernel::intf_get_sides(), luaW_pushfaivariant(), and game_lua_kernel::run_filter().

◆ luaW_toteam()

team* luaW_toteam ( lua_State *  L,
int  idx 
)

Variable Documentation

◆ Team

const char* Team = "side"
static

Implementation for a lua reference to a team, used by the wesnoth in-game sides table.

(The userdata has type team** because lua holds only a pointer to a team, not a full-size team. If it were a full object then we would cast to type team *, since checkudata returns a pointer to the type corresponding to the sizeof expr used when we allocated the userdata.)

Definition at line 43 of file lua_team.cpp.

◆ teamVar

const char teamVar[] = "side variables"
static

Definition at line 44 of file lua_team.cpp.

Referenced by impl_side_get().