44static const char *
Team =
"side";
45static const char teamVar[] =
"side variables";
47#define SIDE_GETTER(name, type) LATTR_GETTER(name, type, team, t)
48#define SIDE_SETTER(name, type) LATTR_SETTER(name, type, team, t)
52 inline static auto metatable =
Team;
73 t.set_gold(
static_cast<int>(
value));
77 return t.objectives();
81 t.set_objectives(
value,
true);
85 return t.village_gold();
93 return t.village_support();
97 t.set_village_support(
value);
101 return t.villages().size();
105 return t.recall_cost();
113 return t.base_income();
121 return t.total_income();
125 return t.objectives_changed();
129 t.set_objectives_changed(
value);
141 return t.uses_shroud();
157 return t.get_scroll_to_leader();
161 t.set_scroll_to_leader(
value);
166 disp->reinit_flags_for_team(
t);
197 return t.user_team_name();
201 t.change_team(
t.team_name(),
value);
205 return t.team_name();
209 t.change_team(
value,
t.user_team_name());
217 return t.faction_name();
225 t.change_controller_by_wml(
value);
237 t.set_defeat_condition_string(
value);
247 t.set_share_vision(*v);
249 throw luaL_argerror(L, 3,
"Invalid share_vision value (should be 'all', 'none', or 'shroud')");
254 return t.carryover_bonus();
258 t.set_carryover_bonus(
value);
262 return t.carryover_percentage();
266 t.set_carryover_percentage(
value);
270 return t.carryover_gold();
274 t.set_carryover_gold(
value);
278 return t.carryover_add();
282 t.set_carryover_add(
value);
294 return t.persistent();
302 return t.no_turn_confirmation();
306 t.set_no_turn_confirmation(
value);
310 return t.share_maps();
314 return t.share_view();
318 return t.chose_random();
322 return t.side_name_tstr();
330 return t.shroud_data();
335 t.merge_shroud_map_data(
value);
348 lua_createtable(L, 1, 0);
350 lua_rawseti(L, -2, 1);
410 std::ostringstream str;
438 lua_pushboolean(L, t1.
side() == t2->side());
440 lua_pushboolean(L,
false);
453 if(!lua_istable(L, 1)) {
456 lua_rawgeti(L, 1, 1);
459 char const *m = luaL_checkstring(L, 2);
474 if(!lua_istable(L, 1)) {
477 lua_rawgeti(L, 1, 1);
480 char const *m = luaL_checkstring(L, 2);
481 if(strcmp(m,
"__cfg") == 0) {
486 if(lua_isnoneornil(L, 3)) {
502 std::ostringstream cmd_out;
504 cmd_out <<
"Adding getside metatable...\n";
506 luaL_newmetatable(L,
Team);
508 static luaL_Reg
const callbacks[] {
516 luaL_setfuncs(L, callbacks, 0);
518 lua_pushstring(L,
Team);
519 lua_setfield(L, -2,
"__metatable");
522 cmd_out <<
"Adding side variables metatable...\n";
526 lua_setfield(L, -2,
"__index");
528 lua_setfield(L, -2,
"__newindex");
529 lua_pushstring(L,
"side variables");
530 lua_setfield(L, -2,
"__metatable");
532 return cmd_out.str();
538 team**
t =
static_cast<team**
>(lua_newuserdatauv(L,
sizeof(
team*), 0));
540 luaL_setmetatable(L,
Team);
545 return **
static_cast<team **
>(luaL_checkudata(L, idx,
Team));
550 if(lua_isinteger(L, idx)) {
551 int side = lua_tointeger(L, idx);
553 std::string error =
"side " + std::to_string(side) +
" does not exist";
554 luaL_argerror(L, 1, error.c_str());
559 return **
static_cast<team **
>(luaL_checkudata(L, idx,
Team));
564 if(
void*
p = luaL_testudata(L, idx,
Team)) {
565 return *
static_cast<team **
>(
p);
A config object defines a single node in a WML file, with access to child nodes.
bool has_team(int side) const
virtual const gamemap & map() const override
static game_display * get_singleton()
map_location starting_position(int side) const
This class stores all the data for a single 'side' (in game nomenclature).
const std::string & side_name() const
Additional functionality for a non-const variable_info.
Information on a WML variable.
config luaW_checkconfig(lua_State *L, int index)
Converts an optional table or vconfig to a config object.
bool luaW_pushvariable(lua_State *L, variable_access_const &v)
int luaW_type_error(lua_State *L, int narg, const char *tname)
bool luaW_checkvariable(lua_State *L, variable_access_create &v, int n)
#define return_cfgref_attrib(name, accessor)
static int impl_side_set(lua_State *L)
Sets some data on a side (__newindex metamethod).
team * luaW_toteam(lua_State *L, int idx)
Test if the top stack element is a team, and if so, return it.
static int impl_side_variables_set(lua_State *L)
Sets the variable of a side (__newindex metamethod).
void luaW_pushteam(lua_State *L, team &tm)
Create a full userdata containing a pointer to the team.
static int impl_side_get(lua_State *L)
Gets some data on a side (__index metamethod).
#define SIDE_SETTER(name, type)
static int impl_side_variables_get(lua_State *L)
Gets the variable of a side (__index metamethod).
static const char teamVar[]
static const char * Team
Implementation for a lua reference to a team, used by the wesnoth in-game sides table.
static int impl_side_equal(lua_State *L)
#define SIDE_GETTER(name, type)
static int impl_side_tostring(lua_State *L)
Turns a lua proxy side to string.
static void reinit_flag_for_team(const team &t)
team & luaW_checkteam(lua_State *L, int idx)
Test if the top stack element is a team, and if not, error.
static int impl_side_dir(lua_State *L)
Gets a list of data on a side (__dir metamethod).
This namespace contains bindings for lua to hold a pointer to a team, and to access and modify it.
std::string register_metatable(lua_State *L)
void lua_push(lua_State *L, const T &val)
std::unique_ptr< MIX_Audio, decltype(&MIX_DestroyAudio)> value
Holds a lookup table for members of one type of object.
int dir(lua_State *L)
Implement __dir metamethod.
int set(lua_State *L)
Implement __newindex metamethod.
int get(lua_State *L)
Implement __index metamethod.
static team & get(lua_State *L, int n)
Encapsulates the map of the game.
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.
static constexpr utils::optional< enum_type > get_enum(const std::string_view value)
Converts a string into its enum equivalent.
static map_location::direction n
variable_info_mutable< variable_info_implementation::vi_policy_throw > variable_access_throw
'Throw if nonexistent' access.