The Battle for Wesnoth  1.15.2+dev
Namespaces | Functions | Variables
lua_unit_type.cpp File Reference
#include "scripting/lua_unit_type.hpp"
#include "scripting/lua_common.hpp"
#include "scripting/lua_unit_attacks.hpp"
#include "scripting/push_check.hpp"
#include "units/types.hpp"
#include <string>
#include <cstring>
#include "lua/lua.h"
#include "lua/lauxlib.h"
Include dependency graph for lua_unit_type.cpp:

Go to the source code of this file.

Namespaces

 lua_unit_type
 This namespace contains bindings for lua to hold a reference to a unit type and access its stats.
 

Functions

static int impl_unit_type_get (lua_State *L)
 Gets some data on a unit type (__index metamethod). More...
 
static int impl_unit_type_equal (lua_State *L)
 
static int impl_unit_type_lookup (lua_State *L)
 
static int impl_unit_type_new (lua_State *L)
 
static int impl_unit_type_count (lua_State *L)
 
static int impl_unit_type_next (lua_State *L)
 
static int impl_unit_type_pairs (lua_State *L)
 
static int impl_unit_type_tostring (lua_State *L)
 Turns a lua proxy unit type to string. More...
 
std::string lua_unit_type::register_metatable (lua_State *L)
 
std::string lua_unit_type::register_table (lua_State *L)
 
void luaW_pushunittype (lua_State *L, const unit_type &ut)
 Create a lua object containing a reference to a unittype, and a metatable to access the properties. More...
 
const unit_typeluaW_tounittype (lua_State *L, int idx)
 Test if a stack element is a unit type, and return it if so. More...
 
const unit_typeluaW_checkunittype (lua_State *L, int idx)
 Test if a stack element is a unit type, and return it if so. More...
 

Variables

static const char UnitType [] = "unit type"
 Implementation for a lua reference to a unit_type. More...
 
static const char UnitTypeTable [] = "unit types"
 

Function Documentation

◆ impl_unit_type_count()

static int impl_unit_type_count ( lua_State L)
static

Definition at line 131 of file lua_unit_type.cpp.

References lua_pushnumber(), unit_type_data::types(), and unit_types.

Referenced by lua_unit_type::register_table().

◆ impl_unit_type_equal()

static int impl_unit_type_equal ( lua_State L)
static

◆ impl_unit_type_get()

static int impl_unit_type_get ( lua_State L)
static

◆ impl_unit_type_lookup()

static int impl_unit_type_lookup ( lua_State L)
static

◆ impl_unit_type_new()

static int impl_unit_type_new ( lua_State L)
static

Definition at line 123 of file lua_unit_type.cpp.

References lua_error(), and lua_pushstring().

Referenced by lua_unit_type::register_table().

◆ impl_unit_type_next()

static int impl_unit_type_next ( lua_State L)
static

◆ impl_unit_type_pairs()

static int impl_unit_type_pairs ( lua_State L)
static

◆ impl_unit_type_tostring()

static int impl_unit_type_tostring ( lua_State L)
static

Turns a lua proxy unit type to string.

(__tostring metamethod)

Definition at line 192 of file lua_unit_type.cpp.

References unit_type::id(), lua_push(), and luaW_checkunittype().

Referenced by lua_unit_type::register_metatable().

◆ luaW_checkunittype()

const unit_type& luaW_checkunittype ( lua_State L,
int  idx 
)

Test if a stack element is a unit type, and return it if so.

Definition at line 257 of file lua_unit_type.cpp.

References luaL_checkudata(), and UnitType.

Referenced by impl_unit_type_equal(), impl_unit_type_get(), and impl_unit_type_tostring().

◆ luaW_pushunittype()

void luaW_pushunittype ( lua_State ,
const unit_type  
)

Create a lua object containing a reference to a unittype, and a metatable to access the properties.

Definition at line 243 of file lua_unit_type.cpp.

References lua_newuserdata(), luaL_setmetatable(), and UnitType.

Referenced by impl_unit_type_lookup(), and impl_unit_type_next().

◆ luaW_tounittype()

const unit_type* luaW_tounittype ( lua_State L,
int  idx 
)

Test if a stack element is a unit type, and return it if so.

Definition at line 249 of file lua_unit_type.cpp.

References luaL_testudata(), p, and UnitType.

Referenced by impl_unit_attacks_get(), impl_unit_attacks_len(), impl_unit_attacks_set(), impl_unit_type_equal(), and lua_gui2::intf_set_dialog_value().

Variable Documentation

◆ UnitType

const char UnitType[] = "unit type"
static

Implementation for a lua reference to a unit_type.

Definition at line 33 of file lua_unit_type.cpp.

Referenced by luaW_checkunittype(), luaW_pushunittype(), luaW_tounittype(), and lua_unit_type::register_metatable().

◆ UnitTypeTable

const char UnitTypeTable[] = "unit types"
static