36 void run(
char const *prog,
const std::string& name,
int nArgs = 0);
39 void throwing_run(
char const * prog,
const std::string& name,
int nArgs,
bool in_interpreter =
false);
56 virtual std::string
my_name() {
return "Basic Lua Kernel"; }
67 virtual void log_error(
char const*
msg,
char const* context =
"Lua error");
104 if (str !=
nullptr) {
131 virtual bool load_string(
char const * prog,
const std::string& name);
155 #define GAME_CONFIG_GETTER(name, type, kernel_type) \
156 LATTR_VALID(name, game_config_tag, k) { return dynamic_cast<kernel_type*>(&k.ref) != nullptr; } \
157 LATTR_GETTER(name, type, game_config_tag, k)
158 #define GAME_CONFIG_SETTER(name, type, kernel_type) \
159 LATTR_VALID(name, game_config_tag, k) { return dynamic_cast<kernel_type*>(&k.ref) != nullptr; } \
160 LATTR_SETTER(name, type, game_config_tag, k)
164 inline static auto metatable =
"game config";
166 return lua_kernel_base::get_lua_kernel<lua_kernel_base>(L);
A config object defines a single node in a WML file, with access to child nodes.
void add_log(const char *str)
void load_core()
Loads the "core" library into the Lua environment.
void run(char const *prog, const std::string &name, int nArgs=0)
Runs a plain script.
virtual void log_error(char const *msg, char const *context="Lua error")
Error reporting mechanisms, used by virtual methods protected_call and load_string.
int intf_dofile(lua_State *L)
Loads and executes a Lua file.
bool load_string(char const *prog, const std::string &name, const error_handler &)
int impl_game_config_get(lua_State *L)
Gets some game_config data (__index metamethod).
int intf_require(lua_State *L)
Loads and executes a Lua file, if there is no corresponding entry in wesnoth.package.
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.
int intf_kernel_type(lua_State *L)
int impl_game_config_set(lua_State *L)
Sets some game_config data (__newindex metamethod).
void load_package()
Loads the package library into lua environment.
void set_external_log(external_log_type lg)
bool protected_call(int nArgs, int nRets, const error_handler &)
void add_log_to_console(const std::string &msg)
int impl_game_config_dir(lua_State *L)
Gets a list of game_config data (__dir metamethod).
int intf_show_lua_console(lua_State *L)
std::vector< std::tuple< std::string, std::string > > registered_widget_definitions_
std::function< void(const std::string &)> external_log_type
static lua_kernel_base *& get_lua_kernel_base_ptr(lua_State *L)
std::vector< std::string > get_global_var_names()
Get tab completion strings.
std::function< void(char const *, char const *)> error_handler
void run_lua_tag(const config &cfg)
Runs a [lua] tag.
static T & get_lua_kernel(lua_State *L)
virtual ~lua_kernel_base()
int intf_print(lua_State *L)
Replacement print function – instead of printing to std::cout, print to the command log.
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 nor...
std::vector< std::string > get_attribute_names(const std::string &var_path)
Gets all attribute names of an extended variable name.
virtual uint32_t get_random_seed()
virtual void throw_exception(char const *msg, char const *context="Lua error")
void add_widget_definition(const std::string &type, const std::string &id)
const std::stringstream & get_log()
Access / manipulate logging of lua kernel activities.
virtual std::string my_name()
User-visible name of the lua kernel that they are talking to.
std::vector< std::string > luaW_get_attributes(lua_State *L, int idx)
This function does the actual work of grabbing all the attribute names.
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
static std::string flush(std::ostringstream &s)
game_config_tag(lua_kernel_base &k)
external_log_type external_log_
command_log & operator<<(const std::string &str)
static game_config_tag get(lua_State *L, int)