The Battle for Wesnoth  1.15.2+dev
Namespaces | Macros | Functions | Variables
lua_terrainmap.cpp File Reference
#include "scripting/lua_terrainmap.hpp"
#include "scripting/lua_terrainfilter.hpp"
#include "formatter.hpp"
#include "log.hpp"
#include "map/location.hpp"
#include "map/map.hpp"
#include "scripting/lua_common.hpp"
#include "scripting/push_check.hpp"
#include "scripting/game_lua_kernel.hpp"
#include "lua/lauxlib.h"
#include "lua/lua.h"
Include dependency graph for lua_terrainmap.cpp:

Go to the source code of this file.

Namespaces

 lua_terrainmap
 

Macros

#define LOG_LUA   LOG_STREAM(info, log_scripting_lua)
 
#define ERR_LUA   LOG_STREAM(err, log_scripting_lua)
 

Functions

bool luaW_isslocs (lua_State *L, int index)
 
mapgen_gamemapluaW_toslocs (lua_State *L, int index)
 
mapgen_gamemapluaW_check_slocs (lua_State *L, int index)
 
void lua_slocs_setmetatable (lua_State *L)
 
void luaW_pushslocs (lua_State *L, int index)
 index the index of the map object. More...
 
int impl_slocs_get (lua_State *L)
 
int impl_slocs_set (lua_State *L)
 
bool luaW_isterrainmap (lua_State *L, int index)
 
mapgen_gamemapluaW_toterrainmap (lua_State *L, int index)
 
mapgen_gamemapluaW_checkterrainmap (lua_State *L, int index)
 
void lua_terrainmap_setmetatable (lua_State *L)
 
template<typename... T>
mapgen_gamemapluaW_pushmap (lua_State *L, T &&... params)
 
int intf_terainmap_create (lua_State *L)
 Create a map. More...
 
static int impl_terainmap_collect (lua_State *L)
 Destroys a map object before it is collected (__gc metamethod). More...
 
static int impl_terainmap_get (lua_State *L)
 Gets some data on a map (__index metamethod). More...
 
static int impl_terainmap_set (lua_State *L)
 Sets some data on a map (__newindex metamethod). More...
 
static int intf_set_terrain (lua_State *L)
 Sets a terrain code. More...
 
static int intf_get_terrain (lua_State *L)
 Gets a terrain code. More...
 
static std::vector< gamemap::overlay_ruleread_rules_vector (lua_State *L, int index)
 
std::string lua_terrainmap::register_metatables (lua_State *L)
 

Variables

static lg::log_domain log_scripting_lua ("scripting/lua")
 
static const char terrinmapKey [] = "terrainmap"
 
static const char maplocationKey [] = "special_locations"
 

Macro Definition Documentation

◆ ERR_LUA

#define ERR_LUA   LOG_STREAM(err, log_scripting_lua)

Definition at line 30 of file lua_terrainmap.cpp.

◆ LOG_LUA

#define LOG_LUA   LOG_STREAM(info, log_scripting_lua)

Definition at line 29 of file lua_terrainmap.cpp.

Function Documentation

◆ impl_slocs_get()

int impl_slocs_get ( lua_State L)

◆ impl_slocs_set()

int impl_slocs_set ( lua_State L)

◆ impl_terainmap_collect()

static int impl_terainmap_collect ( lua_State L)
static

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

Definition at line 256 of file lua_terrainmap.cpp.

References lua_touserdata().

Referenced by lua_terrainmap::register_metatables().

◆ impl_terainmap_get()

static int impl_terainmap_get ( lua_State L)
static

Gets some data on a map (__index metamethod).

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

Definition at line 269 of file lua_terrainmap.cpp.

References luaL_checkstring, luaW_checkterrainmap(), luaW_getmetafield(), luaW_pushslocs(), return_int_attrib, return_string_attrib, mapgen_gamemap::to_string(), mapgen_gamemap::total_height(), and mapgen_gamemap::total_width().

Referenced by lua_terrainmap::register_metatables().

◆ impl_terainmap_set()

static int impl_terainmap_set ( lua_State L)
static

Sets some data on a map (__newindex metamethod).

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

Definition at line 295 of file lua_terrainmap.cpp.

References luaL_argerror(), luaL_checkstring, luaW_checkterrainmap(), and UNUSED.

Referenced by lua_terrainmap::register_metatables().

◆ intf_get_terrain()

static int intf_get_terrain ( lua_State L)
static

Gets a terrain code.

  • Arg 1: map location.
  • Ret 1: string.

Definition at line 340 of file lua_terrainmap.cpp.

References lua_pushstring(), luaW_checklocation(), luaW_checkterrainmap(), t, and t_translation::write_terrain_code().

Referenced by lua_terrainmap::register_metatables().

◆ intf_set_terrain()

static int intf_set_terrain ( lua_State L)
static

Sets a terrain code.

  • Arg 1: map location.
  • Arg 2: terrain code string.
  • Arg 3: layer: (overlay|base|both, default=both)

Definition at line 312 of file lua_terrainmap.cpp.

References terrain_type_data::BASE, terrain_type_data::BOTH, lua_isnoneornil, luaL_checkstring, luaW_checklocation(), luaW_checkterrainmap(), terrain_type_data::OVERLAY, t_translation::read_terrain_code(), mapgen_gamemap::set_terrain(), and gui2::terrain.

Referenced by lua_terrainmap::register_metatables().

◆ intf_terainmap_create()

int intf_terainmap_create ( lua_State L)

Create a map.

  • Arg 1: string descripbing the map data.
  • or:
  • Arg 1: int, width
  • Arg 2: int, height
  • Arg 3: string, terrain

Definition at line 237 of file lua_terrainmap.cpp.

References mapgen_gamemap::h(), lua_isnumber(), lua_tonumber, luaL_checkstring, luaW_pushmap(), t_translation::read_terrain_code(), gui2::terrain, and mapgen_gamemap::w().

Referenced by mapgen_lua_kernel::mapgen_lua_kernel().

◆ lua_slocs_setmetatable()

void lua_slocs_setmetatable ( lua_State L)

Definition at line 66 of file lua_terrainmap.cpp.

References luaL_setmetatable(), and maplocationKey.

◆ lua_terrainmap_setmetatable()

void lua_terrainmap_setmetatable ( lua_State L)

Definition at line 216 of file lua_terrainmap.cpp.

References luaL_setmetatable(), and terrinmapKey.

Referenced by luaW_pushmap().

◆ luaW_check_slocs()

mapgen_gamemap& luaW_check_slocs ( lua_State L,
int  index 
)

Definition at line 57 of file lua_terrainmap.cpp.

References luaW_toslocs(), and luaW_type_error().

Referenced by impl_slocs_get(), and impl_slocs_set().

◆ luaW_checkterrainmap()

mapgen_gamemap& luaW_checkterrainmap ( lua_State L,
int  index 
)

◆ luaW_isslocs()

bool luaW_isslocs ( lua_State L,
int  index 
)

Definition at line 39 of file lua_terrainmap.cpp.

References luaL_testudata(), and maplocationKey.

◆ luaW_isterrainmap()

bool luaW_isterrainmap ( lua_State L,
int  index 
)

Definition at line 193 of file lua_terrainmap.cpp.

References luaL_testudata(), and terrinmapKey.

Referenced by luaW_checkterrainmap(), and luaW_toterrainmap().

◆ luaW_pushmap()

template<typename... T>
mapgen_gamemap* luaW_pushmap ( lua_State L,
T &&...  params 
)

◆ luaW_pushslocs()

void luaW_pushslocs ( lua_State L,
int  index 
)

index the index of the map object.

Definition at line 73 of file lua_terrainmap.cpp.

References lua_createtable(), lua_pushvalue(), lua_rawseti(), lua_remove, luaL_setmetatable(), and maplocationKey.

Referenced by impl_terainmap_get().

◆ luaW_toslocs()

mapgen_gamemap* luaW_toslocs ( lua_State L,
int  index 
)

Definition at line 45 of file lua_terrainmap.cpp.

References lua_istable, lua_pop, lua_rawgeti(), and luaW_toterrainmap().

Referenced by luaW_check_slocs().

◆ luaW_toterrainmap()

mapgen_gamemap* luaW_toterrainmap ( lua_State L,
int  index 
)

Definition at line 199 of file lua_terrainmap.cpp.

References lua_touserdata(), and luaW_isterrainmap().

Referenced by luaW_toslocs().

◆ read_rules_vector()

static std::vector<gamemap::overlay_rule> read_rules_vector ( lua_State L,
int  index 
)
static

Variable Documentation

◆ log_scripting_lua

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

◆ maplocationKey

const char maplocationKey[] = "special_locations"
static

◆ terrinmapKey

const char terrinmapKey[] = "terrainmap"
static