#include <mapgen_lua_kernel.hpp>
Public Member Functions | |
mapgen_lua_kernel (const config *vars) | |
virtual std::string | my_name () |
User-visible name of the lua kernel that they are talking to. More... | |
void | user_config (const char *prog, const config &generator) |
std::string | create_map (const char *prog, const config &generator, utils::optional< uint32_t > seed) |
config | create_scenario (const char *prog, const config &generator, utils::optional< uint32_t > seed) |
virtual uint32_t | get_random_seed () |
std::mt19937 & | get_default_rng () |
Public Member Functions inherited from lua_kernel_base | |
lua_kernel_base () | |
virtual | ~lua_kernel_base () |
void | run_lua_tag (const config &cfg) |
Runs a [lua] tag. More... | |
void | run (char const *prog, const std::string &name, int nArgs=0) |
Runs a plain script. More... | |
void | throwing_run (char const *prog, const std::string &name, int nArgs, bool in_interpreter=false) |
Runs a plain script, but reports errors by throwing lua_error. More... | |
void | interactive_run (char const *prog) |
Tests if a program resolves to an expression, and pretty prints it if it is, otherwise it runs it normally. More... | |
void | load_package () |
Loads the package library into lua environment. More... | |
void | load_core () |
Loads the "core" library into the Lua environment. More... | |
std::vector< std::string > | get_global_var_names () |
Get tab completion strings. More... | |
std::vector< std::string > | get_attribute_names (const std::string &var_path) |
Gets all attribute names of an extended variable name. More... | |
const std::stringstream & | get_log () |
Access / manipulate logging of lua kernel activities. More... | |
void | add_log (const char *str) |
void | clear_log () |
void | set_external_log (external_log_type lg) |
virtual void | log_error (char const *msg, char const *context="Lua error") |
Error reporting mechanisms, used by virtual methods protected_call and load_string. More... | |
virtual void | throw_exception (char const *msg, char const *context="Lua error") |
lua_State * | get_state () |
void | add_widget_definition (const std::string &type, const std::string &id) |
void | add_log_to_console (const std::string &msg) |
int | intf_show_lua_console (lua_State *L) |
Private Member Functions | |
void | run_generator (const char *prog, const config &generator) |
int | intf_get_variable (lua_State *L) |
int | intf_get_all_vars (lua_State *L) |
Private Attributes | |
utils::optional< uint32_t > | random_seed_ |
utils::optional< std::mt19937 > | default_rng_ |
const config * | vars_ |
Additional Inherited Members | |
Public Types inherited from lua_kernel_base | |
using | external_log_type = std::function< void(const std::string &)> |
typedef std::function< void(char const *, char const *)> | error_handler |
Static Public Member Functions inherited from lua_kernel_base | |
template<typename T > | |
static T & | get_lua_kernel (lua_State *L) |
Protected Member Functions inherited from lua_kernel_base | |
int | intf_print (lua_State *L) |
Replacement print function – instead of printing to std::cout, print to the command log. More... | |
bool | protected_call (int nArgs, int nRets, const error_handler &) |
bool | load_string (char const *prog, const std::string &name, const error_handler &) |
virtual bool | protected_call (int nArgs, int nRets) |
virtual bool | load_string (char const *prog, const std::string &name) |
int | intf_dofile (lua_State *L) |
Loads and executes a Lua file. More... | |
int | intf_require (lua_State *L) |
Loads and executes a Lua file, if there is no corresponding entry in wesnoth.package. More... | |
int | intf_kernel_type (lua_State *L) |
int | impl_game_config_get (lua_State *L) |
Gets some game_config data (__index metamethod). More... | |
int | impl_game_config_set (lua_State *L) |
Sets some game_config data (__newindex metamethod). More... | |
int | impl_game_config_dir (lua_State *L) |
Gets a list of game_config data (__dir metamethod). More... | |
Static Protected Member Functions inherited from lua_kernel_base | |
static bool | protected_call (lua_State *L, int nArgs, int nRets, const error_handler &) |
Protected Attributes inherited from lua_kernel_base | |
lua_State * | mState |
command_log | cmd_log_ |
Definition at line 28 of file mapgen_lua_kernel.hpp.
mapgen_lua_kernel::mapgen_lua_kernel | ( | const config * | vars | ) |
Definition at line 236 of file mapgen_lua_kernel.cpp.
References lua_kernel_base::cmd_log_, intf_default_generate(), intf_default_generate_height_map(), intf_find_path(), intf_mg_get_locations(), intf_mg_get_tiles_radius(), intf_random(), intf_terrainfilter_create(), intf_terrainmap_create(), lua_common::intf_tovconfig(), luaW_getglobal(), lua_kernel_base::mState, lua_terrainfilter::register_metatables(), and lua_terrainmap::register_metatables().
std::string mapgen_lua_kernel::create_map | ( | const char * | prog, |
const config & | generator, | ||
utils::optional< uint32_t > | seed | ||
) |
Definition at line 325 of file mapgen_lua_kernel.cpp.
References default_rng_, randomness::generator, get_random_seed(), wfl::msg(), lua_kernel_base::mState, random_seed_, and run_generator().
Referenced by lua_map_generator::create_map().
config mapgen_lua_kernel::create_scenario | ( | const char * | prog, |
const config & | generator, | ||
utils::optional< uint32_t > | seed | ||
) |
Definition at line 341 of file mapgen_lua_kernel.cpp.
References default_rng_, randomness::generator, get_random_seed(), luaW_toconfig(), wfl::msg(), lua_kernel_base::mState, random_seed_, and run_generator().
Referenced by lua_map_generator::create_scenario().
std::mt19937 & mapgen_lua_kernel::get_default_rng | ( | ) |
Definition at line 372 of file mapgen_lua_kernel.cpp.
References default_rng_, and get_random_seed().
|
virtual |
Reimplemented from lua_kernel_base.
Definition at line 362 of file mapgen_lua_kernel.cpp.
References lua_kernel_base::get_random_seed(), and random_seed_.
Referenced by create_map(), create_scenario(), and get_default_rng().
|
private |
Definition at line 320 of file mapgen_lua_kernel.cpp.
References luaW_pushconfig(), and vars_.
|
private |
Definition at line 310 of file mapgen_lua_kernel.cpp.
References luaW_pushvariable(), and vars_.
|
inlinevirtual |
User-visible name of the lua kernel that they are talking to.
Reimplemented from lua_kernel_base.
Definition at line 32 of file mapgen_lua_kernel.hpp.
|
private |
Definition at line 298 of file mapgen_lua_kernel.cpp.
References randomness::generator, lua_kernel_base::load_string(), luaW_pushconfig(), lua_kernel_base::mState, lua_kernel_base::protected_call(), and lua_kernel_base::throw_exception().
Referenced by create_map(), create_scenario(), and user_config().
void mapgen_lua_kernel::user_config | ( | const char * | prog, |
const config & | generator | ||
) |
Definition at line 305 of file mapgen_lua_kernel.cpp.
References randomness::generator, and run_generator().
Referenced by lua_map_generator::user_config().
|
private |
Definition at line 45 of file mapgen_lua_kernel.hpp.
Referenced by create_map(), create_scenario(), and get_default_rng().
|
private |
Definition at line 44 of file mapgen_lua_kernel.hpp.
Referenced by create_map(), create_scenario(), and get_random_seed().
|
private |
Definition at line 46 of file mapgen_lua_kernel.hpp.
Referenced by intf_get_all_vars(), and intf_get_variable().