#include <game_lua_kernel.hpp>
Public Member Functions | |
game_board & | board () |
std::vector< team > & | teams () |
const gamemap & | map () const |
game_display * | get_display () const |
game_lua_kernel (game_state &, play_controller &, reports &) | |
void | set_game_display (game_display *gd) |
virtual std::string | my_name () override |
User-visible name of the lua kernel that they are talking to. More... | |
std::string | apply_effect (const std::string &name, unit &u, const config &cfg, bool need_apply) |
void | initialize (const config &level) |
void | save_game (config &level) |
Executes the game_events.on_save function and adds to cfg the returned tags. More... | |
void | load_game (const config &level) |
Executes the game_events.on_load function and passes to it all the scenario tags not yet handled. More... | |
bool | run_event (const game_events::queued_event &) |
Executes the game_events.on_event function. More... | |
void | custom_command (const std::string &, const config &) |
void | push_builtin_effect () |
Registers a function for use as an effect handler. More... | |
void | set_wml_action (const std::string &, game_events::wml_action::handler) |
Registers a function for use as an action handler. More... | |
void | set_wml_condition (const std::string &, bool(*)(const vconfig &)) |
Registers a function for use as a conditional handler. More... | |
bool | run_wml_action (const std::string &, const vconfig &, const game_events::queued_event &) |
Runs a command from an event handler. More... | |
bool | run_filter (char const *name, const unit &u) |
Runs a script from a unit filter. More... | |
bool | run_filter (char const *name, const map_location &l) |
Runs a script from a location filter. More... | |
bool | run_filter (char const *name, const team &t) |
Runs a script from a location filter. More... | |
bool | run_filter (char const *name, int nArgs) |
Runs a script from a filter. More... | |
bool | run_wml_conditional (const std::string &, const vconfig &) |
Evaluates a WML conidition. More... | |
int | save_wml_event () |
Store a WML event in the Lua registry, as a function. More... | |
int | save_wml_event (const std::string &name, const std::string &id, const std::string &code) |
Store a WML event in the Lua registry, as a function. More... | |
int | save_wml_event (int idx) |
Store a WML event in the Lua registry, as a function. More... | |
void | clear_wml_event (int ref) |
Clear a WML event store in the Lua registry. More... | |
bool | run_wml_event (int ref, const vconfig &args, const game_events::queued_event &ev, bool *out=nullptr) |
Run a WML stored in the Lua registry. More... | |
virtual void | log_error (char const *msg, char const *context="Lua error") override |
Error reporting mechanisms, used by virtual methods protected_call and load_string. More... | |
ai::lua_ai_context * | create_lua_ai_context (char const *code, ai::engine_lua *engine) |
ai::lua_ai_action_handler * | create_lua_ai_action_handler (char const *code, ai::lua_ai_context &context) |
void | mouse_over_hex_callback (const map_location &loc) |
void | select_hex_callback (const map_location &loc) |
void | preload_finished () |
![]() | |
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 | throw_exception (char const *msg, char const *context="Lua error") |
virtual uint32_t | get_random_seed () |
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) |
Public Attributes | |
int | map_locked_ |
A value != 0 means that the shouldn't remove any units from the map, usually because we are currently operating on a unit& and removing it might cause memory corruptions note that we don't check for the dtor of lua owned units because we assume that we operate on such a unit that the lua function that invoked the operation on that unit (like wesnoth.units.add_modification, wesnoth.units.matches ..) have a local copy of that lua_unit* userdata in its stack that prevents it from being collected. More... | |
Private Member Functions | |
unit_map & | units () |
game_data & | gamedata () |
tod_manager & | tod_man () |
const game_events::queued_event & | get_event_info () |
int | intf_allow_end_turn (lua_State *) |
Allow undo sets the flag saying whether the event has mutated the game to false. More... | |
int | intf_allow_undo (lua_State *) |
Allow undo sets the flag saying whether the event has mutated the game to false. More... | |
int | intf_cancel_action (lua_State *) |
int | intf_add_time_area (lua_State *) |
Adding new time_areas dynamically with Standard Location Filters. More... | |
int | intf_remove_time_area (lua_State *) |
Removing new time_areas dynamically with Standard Location Filters. More... | |
int | intf_get_time_area (lua_State *) |
int | intf_animate_unit (lua_State *) |
int | intf_gamestate_inspector (lua_State *) |
int | impl_run_animation (lua_State *) |
int | intf_create_animator (lua_State *) |
int | intf_get_unit (lua_State *) |
Gets the unit at the given location or with the given id. More... | |
int | intf_get_units (lua_State *) |
Gets all the units matching a given filter. More... | |
int | intf_get_displayed_unit (lua_State *) |
Gets the unit displayed in the sidebar. More... | |
int | intf_match_unit (lua_State *L) |
Matches a unit against the given filter. More... | |
int | intf_get_recall_units (lua_State *L) |
Gets the numeric ids of all the units matching a given filter on the recall lists. More... | |
int | intf_get_variable (lua_State *L) |
Gets a WML variable. More... | |
int | intf_set_variable (lua_State *L) |
Sets a WML variable. More... | |
int | intf_highlight_hex (lua_State *L) |
Highlights the given location on the map. More... | |
int | intf_is_enemy (lua_State *L) |
Returns whether the first side is an enemy of the second one. More... | |
int | intf_unit_ability (lua_State *L) |
Returns true if the unit has the given ability enabled. More... | |
int | intf_view_locked (lua_State *L) |
Gets whether gamemap scrolling is disabled for the user. More... | |
int | intf_lock_view (lua_State *L) |
Sets whether gamemap scrolling is disabled for the user. More... | |
int | impl_get_terrain_info (lua_State *L) |
Gets details about a terrain. More... | |
template<bool consider_illuminates> | |
int | intf_get_time_of_day (lua_State *L) |
Gets time of day information. More... | |
int | impl_schedule_get (lua_State *L) |
int | impl_schedule_len (lua_State *L) |
void | luaW_push_schedule (lua_State *L, int area_index) |
int | intf_get_village_owner (lua_State *L) |
Gets the side of a village owner. More... | |
int | intf_set_village_owner (lua_State *L) |
Sets the owner of a village. More... | |
int | intf_get_mouseover_tile (lua_State *L) |
Returns the currently overed tile. More... | |
int | intf_get_selected_tile (lua_State *L) |
Returns the currently selected tile. More... | |
int | impl_game_config_get (lua_State *L) override |
Gets some game_config data (__index metamethod). More... | |
int | impl_game_config_set (lua_State *L) override |
Sets some game_config data (__newindex metamethod). More... | |
int | impl_scenario_get (lua_State *L) |
Gets some scenario data (__index metamethod). More... | |
int | impl_scenario_set (lua_State *L) |
Sets some scenario data (__newindex metamethod). More... | |
int | impl_current_get (lua_State *L) |
Gets some data about current point of game (__index metamethod). More... | |
int | intf_clear_messages (lua_State *) |
Removes all messages from the chat window. More... | |
int | impl_end_level_data_set (lua_State *) |
int | intf_end_turn (lua_State *) |
int | intf_find_cost_map (lua_State *L) |
Is called with one or more units and builds a cost map. More... | |
int | intf_find_path (lua_State *L) |
Finds a path between two locations. More... | |
int | intf_find_reach (lua_State *L) |
Finds all the locations reachable by a unit. More... | |
int | intf_find_vision_range (lua_State *L) |
Finds all the locations for which a given unit would remove the fog (if there was fog on the map). More... | |
int | intf_heal_unit (lua_State *L) |
int | intf_message (lua_State *L) |
Displays a message in the chat window and in the logs. More... | |
int | intf_play_sound (lua_State *L) |
Plays a sound, possibly repeated. More... | |
int | intf_set_achievement (lua_State *L) |
Sets an achievement as being completed. More... | |
int | intf_has_achievement (lua_State *L) |
Returns whether an achievement has been completed. More... | |
int | intf_get_achievement (lua_State *L) |
Returns information on a single achievement, or no data if the achievement is not found. More... | |
int | intf_set_floating_label (lua_State *L, bool spawn) |
Arg 1: text - string Arg 2: options table. More... | |
int | intf_remove_floating_label (lua_State *L) |
int | intf_move_floating_label (lua_State *L) |
void | put_unit_helper (const map_location &loc) |
int | intf_put_unit (lua_State *L) |
Places a unit on the map. More... | |
int | intf_erase_unit (lua_State *L) |
Erases a unit from the map. More... | |
int | intf_put_recall_unit (lua_State *L) |
Puts a unit on a recall list. More... | |
int | intf_extract_unit (lua_State *L) |
Extracts a unit from the map or a recall list and gives it to Lua. More... | |
int | intf_find_vacant_tile (lua_State *L) |
Finds a vacant tile. More... | |
int | intf_float_label (lua_State *L) |
Floats some text on the map. More... | |
int | intf_set_end_campaign_credits (lua_State *L) |
int | intf_set_end_campaign_text (lua_State *L) |
int | intf_clear_menu_item (lua_State *L) |
int | intf_create_side (lua_State *L) |
int | intf_set_menu_item (lua_State *L) |
int | intf_toggle_shroud (lua_State *L, bool place_shroud) |
Toggle shroud on some locations Arg 1: Side number Arg 2: List of locations on which to place/remove shroud. More... | |
int | intf_override_shroud (lua_State *L) |
Overrides the shroud entirely. More... | |
int | intf_simulate_combat (lua_State *L) |
Simulates a combat between two units. More... | |
int | intf_scroll_to_tile (lua_State *L) |
Scrolls to given tile. More... | |
int | intf_select_unit (lua_State *L) |
Selects and highlights the given location on the map. More... | |
int | intf_deselect_hex (lua_State *L) |
Deselects any highlighted hex on the map. More... | |
int | intf_is_skipping_messages (lua_State *L) |
Return true if a replay is in progress but the player has chosen to skip it. More... | |
int | intf_skip_messages (lua_State *L) |
Set whether to skip messages Arg 1 (optional) - boolean. More... | |
int | intf_get_locations (lua_State *L) |
Gets all the locations matching a given filter. More... | |
int | intf_match_location (lua_State *L) |
Matches a location against the given filter. More... | |
int | intf_match_side (lua_State *L) |
Matches a side against the given filter. More... | |
int | intf_set_side_id (lua_State *L) |
int | intf_modify_ai_wml (lua_State *L) |
int | intf_get_sides (lua_State *L) |
Returns a proxy table array for all sides matching the given SSF. More... | |
int | intf_get_side (lua_State *L) |
int | intf_add_tile_overlay (lua_State *L) |
Adds an overlay on a tile. More... | |
int | intf_remove_tile_overlay (lua_State *L) |
Removes an overlay from a tile. More... | |
template<bool is_menu_item> | |
int | intf_add_event_simple (lua_State *L) |
Add a new event handler Arg 1: Event to handle, as a string or list of strings; or menu item ID if this is a menu item Arg 2: The function to call when the event triggers. More... | |
int | intf_add_event_wml (lua_State *L) |
Add a new event handler Arg: A full event specification as a WML config. More... | |
int | intf_add_event (lua_State *L) |
Add a new event handler Arg 1: Table of options. More... | |
int | intf_remove_event (lua_State *L) |
int | intf_color_adjust (lua_State *L) |
int | intf_get_color_adjust (lua_State *L) |
int | intf_screen_fade (lua_State *L) |
int | intf_delay (lua_State *L) |
Delays engine for a while. More... | |
int | intf_add_label (lua_State *L) |
int | intf_remove_label (lua_State *L) |
int | intf_get_label (lua_State *L) |
int | intf_redraw (lua_State *L) |
int | intf_replace_schedule (lua_State *l) |
Replacing the current time of day schedule. More... | |
int | impl_schedule_set (lua_State *L) |
int | intf_scroll (lua_State *L) |
int | intf_get_all_vars (lua_State *L) |
Gets all the WML variables currently set. More... | |
int | impl_theme_item (lua_State *L, std::string name) |
Executes its upvalue as a theme item generator. More... | |
int | impl_theme_items_get (lua_State *L) |
Creates a field of the theme_items table and returns it (__index metamethod). More... | |
int | impl_theme_items_set (lua_State *L) |
Sets a field of the theme_items table (__newindex metamethod). More... | |
int | cfun_builtin_effect (lua_State *L) |
Applies its upvalue as an effect Arg 1: The unit to apply to Arg 3: The [effect] tag contents Arg 3: If false, only build description Return: The description of the effect. More... | |
int | cfun_wml_action (lua_State *L) |
Executes its upvalue as a wml action. More... | |
int | intf_fire_event (lua_State *L, const bool by_id) |
Fires an event. More... | |
int | intf_fire_wml_menu_item (lua_State *L) |
Fires a wml menu item. More... | |
int | intf_teleport (lua_State *L) |
Teeleports a unit to a location. More... | |
int | intf_log (lua_State *L) |
Logs a message Arg 1: (optional) Logger; "wml" for WML errors or deprecations Arg 2: Message Arg 3: Whether to print to chat (always true if arg 1 is "wml") More... | |
int | intf_toggle_fog (lua_State *L, const bool clear) |
Implements the lifting and resetting of fog via WML. More... | |
int | intf_get_fog_or_shroud (lua_State *L, bool fog) |
int | intf_log_replay (lua_State *L) |
int | intf_zoom (lua_State *L) |
std::string | synced_state () |
converts synced_context::get_synced_state() to a string. More... | |
void | lua_chat (const std::string &caption, const std::string &msg) |
std::vector< int > | get_sides_vector (const vconfig &cfg) |
Gets a vector of sides from side= attribute in a given config node. More... | |
Static Private Member Functions | |
static void | extract_preload_scripts (const game_config_view &game_config) |
Private Attributes | |
game_display * | game_display_ |
game_state & | game_state_ |
play_controller & | play_controller_ |
reports & | reports_ |
config | level_lua_ |
int | EVENT_TABLE |
bool | has_preloaded_ = false |
std::stack< game_events::queued_event const *> | queued_events_ |
Static Private Attributes | |
static std::vector< config > | preload_scripts |
static config | preload_config |
Friends | |
class | game_config_manager |
Additional Inherited Members | |
![]() | |
using | external_log_type = std::function< void(const std::string &)> |
typedef std::function< void(char const *, char const *)> | error_handler |
![]() | |
template<typename T > | |
static T & | get_lua_kernel (lua_State *L) |
![]() | |
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, error_handler) |
bool | load_string (char const *prog, const std::string &name, 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) |
![]() | |
static bool | protected_call (lua_State *L, int nArgs, int nRets, error_handler) |
![]() | |
lua_State * | mState |
command_log | cmd_log_ |
Definition at line 48 of file game_lua_kernel.hpp.
game_lua_kernel::game_lua_kernel | ( | game_state & | gs, |
play_controller & | pc, | ||
reports & | reports_object | ||
) |
Definition at line 4717 of file game_lua_kernel.cpp.
References unit::builtin_effects, lua_kernel_base::cmd_log_, EVENT_TABLE, play_controller::get_classification(), game_events::builtin_conditions::have_location(), game_events::builtin_conditions::have_unit(), ai::lua_ai_context::init(), intf_add_known_unit(), intf_add_modification(), intf_advance_unit(), intf_append_ai(), intf_copy_unit(), intf_create_attack(), intf_create_unit(), intf_debug_ai(), intf_do_unsynced(), intf_eval_conditional(), intf_get_era(), intf_get_resource(), intf_get_viewing_side(), intf_handle_user_interact(), intf_invoke_synced_command(), intf_modify_ai(), intf_modify_ai_old(), intf_on_board(), intf_on_border(), intf_remove_modifications(), intf_replace_if_failed(), intf_switch_ai(), intf_synchronize_choice(), intf_synchronize_choices(), intf_terrain_mask(), intf_terrainmap_iter(), lua_common::intf_tovconfig(), intf_transform_unit(), intf_unit_defense(), intf_unit_jamming_cost(), intf_unit_movement_cost(), intf_unit_resistance(), intf_unit_vision_cost(), game_classification::is_test(), luaW_getglobal(), lua_kernel_base::mState, play_controller_, push_builtin_effect(), queued_events_, lua_units::register_attacks_metatables(), lua_race::register_metatable(), lua_unit_type::register_metatable(), lua_team::register_metatable(), lua_terrainmap::register_metatables(), lua_units::register_metatables(), lua_unit_type::register_table(), lua_audio::register_table(), lua_common::register_vconfig_metatable(), game_events::wml_action::registry(), lua_cpp::set_functions(), set_wml_action(), set_wml_condition(), and game_events::builtin_conditions::variable_matches().
std::string game_lua_kernel::apply_effect | ( | const std::string & | name, |
unit & | u, | ||
const config & | cfg, | ||
bool | need_apply | ||
) |
Definition at line 5650 of file game_lua_kernel.cpp.
References ERR_LUA, luaW_getglobal(), luaW_pcall(), luaW_pushconfig(), luaW_pushlocalunit(), and lua_kernel_base::mState.
Referenced by unit::add_modification().
game_board & game_lua_kernel::board | ( | ) |
Definition at line 4688 of file game_lua_kernel.cpp.
|
private |
Applies its upvalue as an effect Arg 1: The unit to apply to Arg 3: The [effect] tag contents Arg 3: If false, only build description Return: The description of the effect.
Definition at line 5331 of file game_lua_kernel.cpp.
References unit::apply_builtin_effect(), unit::describe_builtin_effect(), luaW_checkconfig(), luaW_checkunit(), and luaW_toboolean().
|
private |
Executes its upvalue as a wml action.
Definition at line 5381 of file game_lua_kernel.cpp.
References get_event_info(), h, and luaW_checkvconfig().
void game_lua_kernel::clear_wml_event | ( | int | ref | ) |
Clear a WML event store in the Lua registry.
ref | The unique index into the EVENT_TABLE within the Lua registry |
Definition at line 5554 of file game_lua_kernel.cpp.
References EVENT_TABLE, and lua_kernel_base::mState.
ai::lua_ai_action_handler * game_lua_kernel::create_lua_ai_action_handler | ( | char const * | code, |
ai::lua_ai_context & | context | ||
) |
Definition at line 5721 of file game_lua_kernel.cpp.
References ai::lua_ai_action_handler::create(), and lua_kernel_base::mState.
ai::lua_ai_context * game_lua_kernel::create_lua_ai_context | ( | char const * | code, |
ai::engine_lua * | engine | ||
) |
Definition at line 5716 of file game_lua_kernel.cpp.
References ai::lua_ai_context::create(), and lua_kernel_base::mState.
void game_lua_kernel::custom_command | ( | const std::string & | name, |
const config & | cfg | ||
) |
Definition at line 5313 of file game_lua_kernel.cpp.
References luaW_getglobal(), luaW_pcall(), luaW_pushconfig(), and lua_kernel_base::mState.
Referenced by SYNCED_COMMAND_HANDLER_FUNCTION().
|
staticprivate |
Definition at line 177 of file game_lua_kernel.cpp.
References game_config_view::child(), and game_config_view::child_range().
Referenced by game_config_manager::load_game_config().
|
private |
Definition at line 4704 of file game_lua_kernel.cpp.
|
inline |
Definition at line 197 of file game_lua_kernel.hpp.
|
private |
Definition at line 4712 of file game_lua_kernel.cpp.
Referenced by cfun_wml_action().
|
private |
Gets a vector of sides from side= attribute in a given config node.
Promotes consistent behavior.
Definition at line 204 of file game_lua_kernel.cpp.
References vconfig::child(), config_attribute_value::empty(), side_filter::get_teams(), vconfig::null(), config_attribute_value::str(), and WRN_LUA.
|
private |
Gets some data about current point of game (__index metamethod).
Definition at line 1693 of file game_lua_kernel.cpp.
References config::add_child(), config::child(), events::commands_disabled, game_events::queued_event::data, config_attribute_value::empty(), game_events::entity_location::filter_loc(), gamedata, game_events::queued_event::id, intf_terrainmap_get(), game_events::queued_event::loc1, game_events::queued_event::loc2, luaW_pushconfig(), game_events::queued_event::name, game_data::PLAY, return_bool_attrib, return_int_attrib, return_string_attrib, map_location::valid(), map_location::wml_x(), and map_location::wml_y().
|
private |
Definition at line 1387 of file game_lua_kernel.cpp.
References transient_end_level::carryover_report, data, transient_end_level::linger_mode, modify_bool_attrib, modify_string_attrib, end_level_data::prescenario_save, end_level_data::replay_save, transient_end_level::reveal_map, end_level_data::test_result, and end_level_data::transient.
|
overrideprivatevirtual |
Gets some game_config data (__index metamethod).
Reimplemented from lua_kernel_base.
Definition at line 1270 of file game_lua_kernel.cpp.
References resources::classification, game_classification::era_id, gamedata, game_config_manager::get(), string_enums::enum_base< Definition >::get_string(), lua_kernel_base::impl_game_config_get(), INDEFINITE, LOG_LUA, luaW_pushconfig(), next_scenario, return_bool_attrib, return_cfgref_attrib_deprecated, return_int_attrib_deprecated, return_string_attrib, return_string_attrib_deprecated, return_vector_string_attrib_deprecated, utils::split(), mp_game_settings::to_config(), unit_type_data::traits(), game_classification::type, and unit_types.
|
overrideprivatevirtual |
Sets some game_config data (__newindex metamethod).
Reimplemented from lua_kernel_base.
Definition at line 1322 of file game_lua_kernel.cpp.
References game_config::base_income, game_config::combat_experience, game_config_view::find_child(), game_config_manager::game_config(), gamedata, game_config_manager::get(), lua_kernel_base::impl_game_config_set(), INDEFINITE, game_config::kill_experience, LOG_LUA, modify_bool_attrib, modify_int_attrib, modify_int_attrib_deprecated, modify_string_attrib, modify_string_attrib_deprecated, modify_vector_string_attrib_deprecated, game_config::poison_amount, game_config::recall_cost, game_config::rest_heal_amount, preferences::set_theme(), game_config::village_income, and game_config::village_support.
|
private |
Gets details about a terrain.
Definition at line 1038 of file game_lua_kernel.cpp.
References terrain_type::description(), terrain_type::editor_image(), terrain_type::editor_name(), terrain_type::gives_healing(), terrain_type::icon_image(), terrain_type::id(), lg::info(), terrain_type::is_castle(), terrain_type::is_keep(), terrain_type::is_village(), terrain_type::light_bonus(), lua_push(), luaW_pushtstring(), terrain_type::name(), t_translation::NONE_TERRAIN, t_translation::read_terrain_code(), and t.
|
private |
Definition at line 373 of file game_lua_kernel.cpp.
References animatorKey, unit_animator::clear(), video::headless(), unit_animator::set_all_standing(), unit_animator::start_animations(), and unit_animator::wait_for_end().
|
private |
Gets some scenario data (__index metamethod).
Definition at line 1544 of file game_lua_kernel.cpp.
References game_classification::active_mods, game_classification::campaign, resources::classification, data, game_classification::difficulty, game_classification::end_credits, game_classification::end_text, game_classification::end_text_duration, game_classification::era_id, gamedata, string_enums::enum_base< Definition >::get_string(), impl_end_level_data_collect(), impl_end_level_data_get(), impl_mp_settings_get(), impl_mp_settings_len(), game_classification::is_multiplayer(), LOG_LUA, lua_push(), next_scenario, return_bool_attrib, return_cfgref_attrib, return_int_attrib, return_string_attrib, return_tstring_attrib, return_vector_string_attrib, utils::split(), and game_classification::type.
|
private |
Sets some scenario data (__newindex metamethod).
Definition at line 1629 of file game_lua_kernel.cpp.
References transient_end_level::carryover_report, resources::classification, data, vconfig::empty(), game_classification::end_credits, game_classification::end_text, game_classification::end_text_duration, gamedata, end_level_data::is_victory, transient_end_level::linger_mode, LOG_LUA, luaW_checkvconfig(), modify_bool_attrib, modify_int_attrib, modify_string_attrib, modify_tstring_attrib, modify_vector_string_attrib, end_level_data::prescenario_save, end_level_data::proceed_to_next_level, end_level_data::replay_save, transient_end_level::reveal_map, end_level_data::test_result, and end_level_data::transient.
|
private |
Definition at line 921 of file game_lua_kernel.cpp.
References i, luaW_check_schedule(), luaW_getglobal(), luaW_push_locationset(), luaW_push_tod(), return_int_attrib, and return_string_attrib.
|
private |
Definition at line 954 of file game_lua_kernel.cpp.
References luaW_check_schedule().
|
private |
Definition at line 962 of file game_lua_kernel.cpp.
References lg::err(), i, id, lua_push(), luaW_check_locationset(), luaW_check_schedule(), luaW_checkconfig(), modify_int_attrib, modify_string_attrib, and n.
|
private |
Executes its upvalue as a theme item generator.
Definition at line 4467 of file game_lua_kernel.cpp.
References luaW_pushconfig().
Referenced by impl_theme_items_get().
|
private |
Creates a field of the theme_items table and returns it (__index metamethod).
Definition at line 4477 of file game_lua_kernel.cpp.
References impl_theme_item(), and lua_cpp::push_closure().
|
private |
Sets a field of the theme_items table (__newindex metamethod).
Definition at line 4491 of file game_lua_kernel.cpp.
void game_lua_kernel::initialize | ( | const config & | level | ) |
Definition at line 5161 of file game_lua_kernel.cpp.
References config::append_children(), config::child_range(), lua_kernel_base::cmd_log_, config::empty(), level_lua_, game_config::load_config(), luaW_pushracetable(), lua_kernel_base::mState, and lua_kernel_base::run_lua_tag().
|
private |
Add a new event handler Arg 1: Table of options.
name: Event to handle, as a string or list of strings id: Event ID menu_item: True if this is a menu item (an ID is required); this means removing the menu item will automatically remove this event. Default false. first_time_only: Whether this event should fire again after the first time; default true. filter: Event filters as a config with filter tags, a table of the form {filter_type = filter_contents}, or a function content: The content of the event. This is a WML table passed verbatim into the event when it fires. If no function is specified, it will be interpreted as ActionWML. action: The function to call when the event triggers. Defaults to wesnoth.wml_actions.command.
Definition at line 3835 of file game_lua_kernel.cpp.
References game_events::manager::add_event_handler_from_lua(), id, luaW_table_get_def(), luaW_tableget(), luaW_toconfig(), read_event_name(), READ_ONE_FILTER, s, and game_events::event_handler::set_arguments().
|
private |
Add a new event handler Arg 1: Event to handle, as a string or list of strings; or menu item ID if this is a menu item Arg 2: The function to call when the event triggers.
Definition at line 3913 of file game_lua_kernel.cpp.
References game_events::manager::add_event_handler_from_lua(), id, read_event_name(), and game_events::event_handler::set_arguments().
|
private |
Add a new event handler Arg: A full event specification as a WML config.
Definition at line 3937 of file game_lua_kernel.cpp.
References game_events::manager::add_event_handler_from_wml(), vconfig::get_config(), vconfig::get_parsed_config(), and luaW_checkvconfig().
|
private |
Definition at line 4018 of file game_lua_kernel.cpp.
References vconfig::get_config(), label, display::labels(), luaW_checkvconfig(), and map_labels::set_label().
|
private |
Adds an overlay on a tile.
Definition at line 3724 of file game_lua_kernel.cpp.
References vconfig::child(), side_filter::get_teams(), utils::join(), luaW_checklocation(), luaW_checkvconfig(), and vconfig::null().
|
private |
Adding new time_areas dynamically with Standard Location Filters.
Arg 1: Area ID Arg 2: Area locations (either a filter or a list of locations) Arg 3: (optional) Area schedule - WML table with [time] tags and optional current_time=
Definition at line 4333 of file game_lua_kernel.cpp.
References deprecated_message(), vconfig::get_parsed_config(), id, INDEFINITE, LOG_LUA, log_scope, luaW_check_locationset(), luaW_checkconfig(), luaW_checkvconfig(), and luaW_tovconfig().
|
private |
Allow undo sets the flag saying whether the event has mutated the game to false.
Definition at line 4295 of file game_lua_kernel.cpp.
References gamedata, luaW_iststring(), luaW_toboolean(), and luaW_totstring().
|
private |
Allow undo sets the flag saying whether the event has mutated the game to false.
Definition at line 4311 of file game_lua_kernel.cpp.
References luaW_toboolean().
|
private |
|
private |
Definition at line 4322 of file game_lua_kernel.cpp.
|
private |
Definition at line 728 of file game_lua_kernel.cpp.
References utils::split(), utils::STRIP_SPACES, and WRN_LUA.
|
private |
Removes all messages from the chat window.
Definition at line 1787 of file game_lua_kernel.cpp.
|
private |
Definition at line 3956 of file game_lua_kernel.cpp.
|
private |
Definition at line 401 of file game_lua_kernel.cpp.
References animatorKey, impl_add_animation(), impl_animator_collect(), impl_animator_get(), and impl_clear_animation().
|
private |
Definition at line 712 of file game_lua_kernel.cpp.
References luaW_checkconfig(), and utf8::size().
|
private |
Delays engine for a while.
Definition at line 3995 of file game_lua_kernel.cpp.
References gamedata, game_data::INITIAL, luaW_toboolean(), game_data::PRELOAD, and game_data::PRESTART.
|
private |
Deselects any highlighted hex on the map.
No arguments or return values
Definition at line 3216 of file game_lua_kernel.cpp.
References map_location::null_location().
|
private |
Definition at line 1795 of file game_lua_kernel.cpp.
References resources::controller, play_controller::gamestate(), and game_state::next_player_number_.
|
private |
Erases a unit from the map.
Definition at line 2596 of file game_lua_kernel.cpp.
References recall_list_manager::erase_if_matches_id(), unit::get_location(), unit::id(), luaW_checkunit_ref(), luaW_isunit(), luaW_tolocation(), lua_unit::on_map(), lua_unit::on_recall_list(), team::recall_list(), t, and resources::whiteboard.
|
private |
Extracts a unit from the map or a recall list and gives it to Lua.
Definition at line 2684 of file game_lua_kernel.cpp.
References recall_list_manager::erase_if_matches_id(), luaW_checkunit_ref(), team::recall_list(), and t.
|
private |
Is called with one or more units and builds a cost map.
Definition at line 2128 of file game_lua_kernel.cpp.
References pathfind::full_cost_map::add_unit(), unit_filter::all_matches_on_map(), debug, resources::fake_units, unit_type_data::find(), pathfind::full_cost_map::get_pair_at(), i, load_fake_units(), luaW_checklocation(), luaW_push_namedtuple(), luaW_toboolean(), luaW_tounit(), luaW_tovconfig(), vconfig::null(), s, utf8::size(), vconfig::unconstructed_vconfig(), unit_types, and unit_map::iterator_base< iter_types >::valid().
|
private |
Finds a path between two locations.
Definition at line 1834 of file game_lua_kernel.cpp.
References pathfind::a_star_search(), deprecated_message(), FOR_REMOVAL, unit::get_location(), unit_map::iterator_base< iter_types >::get_shared_ptr(), pathfind::get_teleport_locations(), gamemap_base::h(), i, luaW_checklocation(), luaW_checkunit(), luaW_pushlocation(), pathfind::plain_route::move_cost, unit::side(), utf8::size(), pathfind::plain_route::steps, unit_map::iterator_base< iter_types >::valid(), and gamemap_base::w().
|
private |
Finds all the locations reachable by a unit.
Definition at line 1949 of file game_lua_kernel.cpp.
References pathfind::paths::step::curr, deprecated_message(), pathfind::paths::destinations, FOR_REMOVAL, unit_map::iterator_base< iter_types >::get_shared_ptr(), i, luaW_checklocation(), luaW_checkunit(), luaW_push_namedtuple(), pathfind::paths::step::move_left, s, unit::side(), utf8::size(), unit_map::iterator_base< iter_types >::valid(), map_location::wml_x(), and map_location::wml_y().
|
private |
Finds a vacant tile.
Definition at line 2716 of file game_lua_kernel.cpp.
References unit::create(), pathfind::find_vacant_tile(), luaW_checkconfig(), luaW_checklocation(), luaW_checkunit_ptr(), luaW_isunit(), pathfind::VACANT_ANY, map_location::valid(), map_location::wml_x(), and map_location::wml_y().
|
private |
Finds all the locations for which a given unit would remove the fog (if there was fog on the map).
Definition at line 2024 of file game_lua_kernel.cpp.
References actions::create_jamming_map(), d, e, resources::gameboard, unit::get_location(), unit_map::iterator_base< iter_types >::get_shared_ptr(), luaW_checklocation(), luaW_checkunit(), luaW_push_namedtuple(), unit::side(), and unit_map::iterator_base< iter_types >::valid().
|
private |
Fires an event.
Definition at line 617 of file game_lua_kernel.cpp.
References config::add_child(), b, config::child(), data, config::has_child(), luaW_toconfig(), luaW_tolocation(), and config::remove_children().
|
private |
Fires a wml menu item.
NOTE: This is not an "official" feature, it may currently cause assertion failures if used with menu items which have "needs_select". It is not supported right now to use it this way. The purpose of this function right now is to make it possible to have automated sanity tests for the wml menu items system.
Definition at line 669 of file game_lua_kernel.cpp.
References b, gamedata, and luaW_checklocation().
|
private |
Floats some text on the map.
Definition at line 2745 of file game_lua_kernel.cpp.
References color_t::from_rgb_string(), font::LABEL_COLOR, luaW_checklocation(), and luaW_checktstring().
|
private |
Definition at line 421 of file game_lua_kernel.cpp.
References gamedata, luaW_checkvconfig(), and lua_gui2::show_gamestate_inspector().
|
private |
Returns information on a single achievement, or no data if the achievement is not found.
Definition at line 3126 of file game_lua_kernel.cpp.
References ERR_LUA, game_config_manager::get(), and luaW_pushconfig().
|
private |
Gets all the WML variables currently set.
Definition at line 4505 of file game_lua_kernel.cpp.
References gamedata, and luaW_pushconfig().
|
private |
Definition at line 3965 of file game_lua_kernel.cpp.
|
private |
Gets the unit displayed in the sidebar.
Definition at line 466 of file game_lua_kernel.cpp.
References luaW_pushunit(), and unit_map::iterator_base< iter_types >::valid().
|
private |
Definition at line 4590 of file game_lua_kernel.cpp.
References team::fogged(), luaW_checklocation(), luaW_checkteam(), team::shrouded(), and t.
|
private |
Definition at line 4053 of file game_lua_kernel.cpp.
References schema_validation::at(), map_labels::get_label(), label, display::labels(), luaW_checklocation(), luaW_checkteam(), luaW_pushconfig(), n, and terrain_label::write().
|
private |
Gets all the locations matching a given filter.
Definition at line 3400 of file game_lua_kernel.cpp.
References luaW_checkvconfig(), luaW_isunit(), luaW_push_locationset(), and luaW_tounit().
|
private |
Returns the currently overed tile.
Definition at line 1201 of file game_lua_kernel.cpp.
References map_location::wml_x(), and map_location::wml_y().
|
private |
Gets the numeric ids of all the units matching a given filter on the recall lists.
Definition at line 579 of file game_lua_kernel.cpp.
References i, luaW_checkvconfig(), luaW_pushunit(), vconfig::null(), s, and t.
|
private |
Returns the currently selected tile.
Definition at line 1219 of file game_lua_kernel.cpp.
References map_location::wml_x(), and map_location::wml_y().
|
private |
Definition at line 3582 of file game_lua_kernel.cpp.
References i, luaW_pushteam(), and utf8::size().
|
private |
Returns a proxy table array for all sides matching the given SSF.
Definition at line 3595 of file game_lua_kernel.cpp.
References side_filter::get_teams(), utf8::index(), LOG_LUA, luaW_checkvconfig(), luaW_pushteam(), and vconfig::null().
|
private |
Definition at line 4380 of file game_lua_kernel.cpp.
References luaW_tolocation().
|
private |
Gets time of day information.
Definition at line 1079 of file game_lua_kernel.cpp.
References luaW_check_schedule(), luaW_push_tod(), and luaW_tolocation().
|
private |
Gets the unit at the given location or with the given id.
Definition at line 437 of file game_lua_kernel.cpp.
References id, luaW_pushunit(), luaW_tolocation(), and unit_map::iterator_base< iter_types >::valid().
|
private |
Gets all the units matching a given filter.
Definition at line 490 of file game_lua_kernel.cpp.
References unit_filter::all_matches_at(), unit_filter::all_matches_on_map(), unit_filter::all_matches_with_unit(), i, luaW_checkvconfig(), luaW_pushunit(), luaW_tolocation(), luaW_tounit(), and map_location::valid().
|
private |
Gets a WML variable.
Definition at line 686 of file game_lua_kernel.cpp.
References gamedata, and luaW_pushvariable().
|
private |
Gets the side of a village owner.
Definition at line 1126 of file game_lua_kernel.cpp.
References luaW_checklocation().
|
private |
Returns whether an achievement has been completed.
Definition at line 3105 of file game_lua_kernel.cpp.
References preferences::achievement(), resources::controller, ERR_LUA, and synced_context::is_synced().
|
private |
|
private |
Highlights the given location on the map.
Definition at line 802 of file game_lua_kernel.cpp.
References luaW_checklocation().
|
private |
Returns whether the first side is an enemy of the second one.
Definition at line 821 of file game_lua_kernel.cpp.
References luaW_toteam(), utf8::size(), and t.
|
private |
Return true if a replay is in progress but the player has chosen to skip it.
Definition at line 3228 of file game_lua_kernel.cpp.
|
private |
Sets whether gamemap scrolling is disabled for the user.
Definition at line 857 of file game_lua_kernel.cpp.
References luaW_toboolean().
|
private |
Logs a message Arg 1: (optional) Logger; "wml" for WML errors or deprecations Arg 2: Message Arg 3: Whether to print to chat (always true if arg 1 is "wml")
Definition at line 4575 of file game_lua_kernel.cpp.
References ERR_WML, lg::log_to_chat(), luaW_toboolean(), and wfl::msg().
|
private |
Definition at line 3771 of file game_lua_kernel.cpp.
References replay::add_log_data(), luaW_toconfig(), and resources::recorder.
|
private |
Matches a location against the given filter.
Definition at line 3424 of file game_lua_kernel.cpp.
References luaW_checklocation(), luaW_checkvconfig(), luaW_isunit(), luaW_tounit(), and vconfig::null().
|
private |
Matches a side against the given filter.
Definition at line 3452 of file game_lua_kernel.cpp.
References luaW_checkvconfig(), luaW_toteam(), side_filter::match(), vconfig::null(), utf8::size(), and t.
|
private |
Matches a unit against the given filter.
Definition at line 533 of file game_lua_kernel.cpp.
References recall_list_manager::find_index(), unit::get_location(), unit::id(), luaW_checkunit_ref(), luaW_checkvconfig(), luaW_tolocation(), luaW_tounit(), vconfig::null(), lua_unit::on_recall_list(), team::recall_list(), team::save_id_or_number(), t, and WRN_LUA.
|
private |
Displays a message in the chat window and in the logs.
Definition at line 1753 of file game_lua_kernel.cpp.
References h, LOG_LUA, and luaW_checktstring().
|
private |
|
private |
Definition at line 2322 of file game_lua_kernel.cpp.
References luaW_check_floating_label(), and font::move_floating_label().
|
private |
Overrides the shroud entirely.
All locations are shrouded, except for the ones passed in as argument 2. Arg 1: Side number Arg 2: List of locations that should be unshrouded
Definition at line 777 of file game_lua_kernel.cpp.
References team::clear_shroud(), luaW_check_locationset(), luaW_checkteam(), luaW_type_error(), team::reshroud(), and t.
|
private |
Plays a sound, possibly repeated.
Definition at line 3059 of file game_lua_kernel.cpp.
References sound::play_sound(), and sound::SOUND_FX.
|
private |
Puts a unit on a recall list.
Definition at line 2635 of file game_lua_kernel.cpp.
References recall_list_manager::add(), unit::create(), recall_list_manager::erase_by_underlying_id(), luaW_checkconfig(), luaW_checkunit_ref(), luaW_isunit(), team::recall_list(), utf8::size(), t, and resources::whiteboard.
|
private |
Places a unit on the map.
Definition at line 2541 of file game_lua_kernel.cpp.
References unit::create(), unit::get_location(), lua_unit::get_shared(), luaW_checkconfig(), luaW_checkunit_ref(), luaW_isunit(), luaW_toboolean(), luaW_tolocation(), lua_unit::on_map(), lua_unit::put_map(), map_location::set_wml_x(), map_location::set_wml_y(), and map_location::valid().
|
private |
Definition at line 4089 of file game_lua_kernel.cpp.
References actions::clear_shroud(), side_filter::get_teams(), display::invalidate_all(), luaW_checkvconfig(), luaW_toboolean(), game_display::maybe_rebuild(), and display::recalculate_minimap().
|
private |
Definition at line 3950 of file game_lua_kernel.cpp.
|
private |
Definition at line 2310 of file game_lua_kernel.cpp.
References luaW_check_floating_label(), and font::remove_floating_label().
|
private |
Definition at line 4034 of file game_lua_kernel.cpp.
References luaW_checklocation(), and luaW_table_get_def().
|
private |
Removes an overlay from a tile.
Definition at line 3754 of file game_lua_kernel.cpp.
References luaW_checklocation().
|
private |
Removing new time_areas dynamically with Standard Location Filters.
Definition at line 4369 of file game_lua_kernel.cpp.
|
private |
Replacing the current time of day schedule.
Definition at line 4405 of file game_lua_kernel.cpp.
References ERR_LUA, vconfig::get_children(), vconfig::get_parsed_config(), LOG_LUA, luaW_check_schedule(), and luaW_checkvconfig().
|
private |
Definition at line 3977 of file game_lua_kernel.cpp.
References luaW_type_error().
|
private |
Definition at line 4430 of file game_lua_kernel.cpp.
References luaW_getglobal(), luaW_pcall(), luaW_toconfig(), and n.
|
private |
Scrolls to given tile.
Definition at line 3171 of file game_lua_kernel.cpp.
References luaW_checklocation(), luaW_toboolean(), display::ONSCREEN, display::ONSCREEN_WARP, display::SCROLL, and display::WARP.
|
private |
Selects and highlights the given location on the map.
Definition at line 3194 of file game_lua_kernel.cpp.
References gui2::event::implementation::fire_event(), luaW_checklocation(), luaW_toboolean(), and map_location::null_location().
|
private |
Sets an achievement as being completed.
Definition at line 3073 of file game_lua_kernel.cpp.
References achievement::achieved_, ERR_LUA, game_config_manager::get(), achievement::id_, and preferences::set_achievement().
|
private |
|
private |
|
private |
Arg 1: text - string Arg 2: options table.
Definition at line 2346 of file game_lua_kernel.cpp.
References font::add_floating_label(), impl_floating_label_getmethod(), font::LABEL_COLOR, labelKey, luaW_checktstring(), luaW_table_set(), s, font::floating_label::set_alignment(), font::floating_label::set_bg_color(), font::floating_label::set_clip_rect(), font::floating_label::set_color(), font::floating_label::set_font_size(), font::floating_label::set_lifetime(), font::floating_label::set_position(), utf8::size(), and font::SIZE_SMALL.
|
private |
Definition at line 722 of file game_lua_kernel.cpp.
References luaW_checkvconfig().
|
private |
Definition at line 3474 of file game_lua_kernel.cpp.
References game_config::images::flag, luaW_toteam(), team::set_color(), team::set_flag(), and t.
|
private |
Sets a WML variable.
Definition at line 698 of file game_lua_kernel.cpp.
References gamedata, and luaW_checkvariable().
|
private |
Sets the owner of a village.
Definition at line 1143 of file game_lua_kernel.cpp.
References gamedata, team::get_village(), team::lose_village(), luaW_checklocation(), and luaW_toboolean().
|
private |
Simulates a combat between two units.
Definition at line 3022 of file game_lua_kernel.cpp.
References luaW_checkunit(), luaW_pushsimdata(), and luaW_pushsimweapon().
|
private |
Set whether to skip messages Arg 1 (optional) - boolean.
Definition at line 3242 of file game_lua_kernel.cpp.
References luaW_pcall(), luaW_toboolean(), luaW_toconfig(), and wfl::msg().
|
private |
Teeleports a unit to a location.
Arg 1: unit Arg 2: target location Arg 3: bool (ignore_passability) Arg 4: bool (clear_shroud) Arg 5: bool (animate)
Definition at line 4518 of file game_lua_kernel.cpp.
References actions::shroud_clearer::clear_dest(), actions::clear_shroud(), unit::clear_status_caches(), actions::shroud_clearer::clear_unit(), pathfind::find_vacant_tile(), actions::shroud_clearer::fire_events(), actions::get_village(), luaW_checklocation(), luaW_checkunit_ptr(), luaW_toboolean(), unit_display::move_unit(), and pathfind::VACANT_ANY.
|
private |
Implements the lifting and resetting of fog via WML.
Keeping affect_normal_fog as false causes only the fog override to be affected. Otherwise, fog lifting will be implemented similar to normal sight (cannot be individually reset and ends at the end of the turn), and fog resetting will, in addition to removing overrides, extend the specified teams' normal fog to all hexes.
Arg 1: (optional) Side number, or list of side numbers Arg 2: List of locations; each is a two-element array or a table with x and y keys Arg 3: (optional) boolean
Definition at line 4610 of file game_lua_kernel.cpp.
References team::add_fog_override(), team::clear_fog(), luaW_check_locationset(), luaW_toboolean(), luaW_toteam(), team::refog(), team::remove_fog_override(), utf8::size(), and t.
|
private |
Toggle shroud on some locations Arg 1: Side number Arg 2: List of locations on which to place/remove shroud.
Definition at line 746 of file game_lua_kernel.cpp.
References team::clear_shroud(), luaW_check_locationset(), luaW_checkteam(), team::place_shroud(), and t.
|
private |
Returns true if the unit has the given ability enabled.
Definition at line 2905 of file game_lua_kernel.cpp.
References unit::get_ability_bool(), and luaW_checkunit().
|
private |
Gets whether gamemap scrolling is disabled for the user.
Definition at line 843 of file game_lua_kernel.cpp.
|
private |
Definition at line 1767 of file game_lua_kernel.cpp.
References luaW_toboolean(), and game_config::tile_size.
void game_lua_kernel::load_game | ( | const config & | level | ) |
Executes the game_events.on_load function and passes to it all the scenario tags not yet handled.
Definition at line 5235 of file game_lua_kernel.cpp.
References config::all_children_range(), is_handled_file_tag(), luaW_getglobal(), luaW_pcall(), luaW_pushconfig(), and lua_kernel_base::mState.
|
overridevirtual |
Error reporting mechanisms, used by virtual methods protected_call and load_string.
Reimplemented from lua_kernel_base.
Definition at line 186 of file game_lua_kernel.cpp.
References lua_kernel_base::log_error().
Referenced by run_filter(), and save_game().
|
private |
Definition at line 192 of file game_lua_kernel.cpp.
References events::chat_handler::MESSAGE_PUBLIC.
|
private |
Definition at line 894 of file game_lua_kernel.cpp.
const gamemap & game_lua_kernel::map | ( | ) | const |
Definition at line 4700 of file game_lua_kernel.cpp.
void game_lua_kernel::mouse_over_hex_callback | ( | const map_location & | loc | ) |
Definition at line 5726 of file game_lua_kernel.cpp.
References lua_push(), luaW_getglobal(), luaW_pcall(), lua_kernel_base::mState, map_location::wml_x(), and map_location::wml_y().
|
inlineoverridevirtual |
User-visible name of the lua kernel that they are talking to.
Reimplemented from lua_kernel_base.
Definition at line 211 of file game_lua_kernel.hpp.
References preferences::custom_command(), game_config::images::level, wfl::msg(), and t.
|
inline |
Definition at line 273 of file game_lua_kernel.hpp.
void game_lua_kernel::push_builtin_effect | ( | ) |
Registers a function for use as an effect handler.
Definition at line 5356 of file game_lua_kernel.cpp.
References lua_kernel_base::mState.
Referenced by game_lua_kernel().
|
private |
Definition at line 2522 of file game_lua_kernel.cpp.
References resources::whiteboard.
bool game_lua_kernel::run_event | ( | const game_events::queued_event & | ev | ) |
Executes the game_events.on_event function.
Returns false if there was no lua handler for this event
Definition at line 5300 of file game_lua_kernel.cpp.
References luaW_getglobal(), luaW_pcall(), lua_kernel_base::mState, game_events::queued_event::name, and queued_events_.
Referenced by game_events::wml_event_pump::operator()().
bool game_lua_kernel::run_filter | ( | char const * | name, |
const unit & | u | ||
) |
Runs a script from a unit filter.
The script is an already compiled function given by its name.
Definition at line 5610 of file game_lua_kernel.cpp.
References luaW_pushlocalunit(), and lua_kernel_base::mState.
Referenced by side_filter::match_internal(), and run_filter().
bool game_lua_kernel::run_filter | ( | char const * | name, |
const map_location & | l | ||
) |
Runs a script from a location filter.
The script is an already compiled function given by its name.
Definition at line 5588 of file game_lua_kernel.cpp.
References lua_kernel_base::mState, run_filter(), map_location::wml_x(), and map_location::wml_y().
bool game_lua_kernel::run_filter | ( | char const * | name, |
const team & | t | ||
) |
Runs a script from a location filter.
The script is an already compiled function given by its name.
Definition at line 5599 of file game_lua_kernel.cpp.
References luaW_pushteam(), lua_kernel_base::mState, and run_filter().
bool game_lua_kernel::run_filter | ( | char const * | name, |
int | nArgs | ||
) |
Runs a script from a filter.
The script is an already compiled function given by its name.
Definition at line 5628 of file game_lua_kernel.cpp.
References b, log_error(), luaW_getglobal(), luaW_pcall(), luaW_toboolean(), lua_kernel_base::mState, game_config::path, utils::split(), and utils::STRIP_SPACES.
bool game_lua_kernel::run_wml_action | ( | const std::string & | cmd, |
const vconfig & | cfg, | ||
const game_events::queued_event & | ev | ||
) |
Runs a command from an event handler.
Definition at line 5446 of file game_lua_kernel.cpp.
References luaW_getglobal(), luaW_pcall(), luaW_pushvconfig(), lua_kernel_base::mState, and queued_events_.
Referenced by actions::undo_action::undo_action().
bool game_lua_kernel::run_wml_conditional | ( | const std::string & | cmd, |
const vconfig & | cfg | ||
) |
Evaluates a WML conidition.
Definition at line 5469 of file game_lua_kernel.cpp.
References b, ERR_WML, lg::log_to_chat(), luaW_getglobal(), luaW_pcall(), luaW_pushvconfig(), luaW_toboolean(), and lua_kernel_base::mState.
bool game_lua_kernel::run_wml_event | ( | int | ref, |
const vconfig & | args, | ||
const game_events::queued_event & | ev, | ||
bool * | out = nullptr |
||
) |
Run a WML stored in the Lua registry.
ref | The unique index into the EVENT_TABLE within the Lua registry |
args | Arguments to pass to the event function, as a config |
ev | The event data for the event being fired |
out | If non-null, receives the result of the called function (provided it is a boolean value) |
Definition at line 5562 of file game_lua_kernel.cpp.
References EVENT_TABLE, luaW_pcall(), luaW_pushvconfig(), luaW_toboolean(), lua_kernel_base::mState, ON_SCOPE_EXIT, and queued_events_.
Referenced by game_events::event_handler::handle_event().
void game_lua_kernel::save_game | ( | config & | cfg | ) |
Executes the game_events.on_save function and adds to cfg the returned tags.
Also flushes the [lua] tags.
Definition at line 5262 of file game_lua_kernel.cpp.
References config::erase(), i, is_handled_file_tag(), log_error(), luaW_getglobal(), luaW_pcall(), luaW_toconfig(), lua_kernel_base::mState, config::ordered_begin(), config::ordered_end(), and config::splice_children().
int game_lua_kernel::save_wml_event | ( | ) |
Store a WML event in the Lua registry, as a function.
Uses a default function that interprets ActionWML.
Definition at line 5504 of file game_lua_kernel.cpp.
References EVENT_TABLE, intf_run_event_wml(), lua_kernel_base::mState, and ON_SCOPE_EXIT.
Referenced by lua_event_filter::lua_event_filter(), and game_events::event_handler::register_wml_event().
int game_lua_kernel::save_wml_event | ( | const std::string & | name, |
const std::string & | id, | ||
const std::string & | code | ||
) |
Store a WML event in the Lua registry, as a function.
Compiles the function from the given code.
name | The event name, used to generate a chunk name for the compiled function |
id | The event id, used to generate a chunk name for the compiled function |
code | The actual code of the function |
Definition at line 5516 of file game_lua_kernel.cpp.
References ERR_LUA, EVENT_TABLE, lua_kernel_base::load_string(), lua_kernel_base::mState, and ON_SCOPE_EXIT.
int game_lua_kernel::save_wml_event | ( | int | idx | ) |
Store a WML event in the Lua registry, as a function.
Uses the function at the specified Lua stack index.
idx | The Lua stack index of the function to store |
Definition at line 5541 of file game_lua_kernel.cpp.
References EVENT_TABLE, lua_kernel_base::mState, and ON_SCOPE_EXIT.
void game_lua_kernel::select_hex_callback | ( | const map_location & | loc | ) |
Definition at line 5739 of file game_lua_kernel.cpp.
References lua_push(), luaW_getglobal(), luaW_pcall(), lua_kernel_base::mState, map_location::wml_x(), and map_location::wml_y().
void game_lua_kernel::set_game_display | ( | game_display * | gd | ) |
Definition at line 5188 of file game_lua_kernel.cpp.
References game_display_.
void game_lua_kernel::set_wml_action | ( | const std::string & | cmd, |
game_events::wml_action::handler | h | ||
) |
Registers a function for use as an action handler.
Definition at line 5394 of file game_lua_kernel.cpp.
References lua_kernel_base::mState.
Referenced by game_lua_kernel().
void game_lua_kernel::set_wml_condition | ( | const std::string & | , |
bool(*)(const vconfig &) | |||
) |
Registers a function for use as a conditional handler.
Definition at line 5426 of file game_lua_kernel.cpp.
References cfun_wml_condition(), and lua_kernel_base::mState.
Referenced by game_lua_kernel().
|
private |
converts synced_context::get_synced_state() to a string.
Definition at line 1666 of file game_lua_kernel.cpp.
References gamedata, synced_context::get_synced_state(), game_data::INITIAL, synced_context::LOCAL_CHOICE, game_data::PRELOAD, synced_context::SYNCED, and synced_context::UNSYNCED.
std::vector< team > & game_lua_kernel::teams | ( | ) |
Definition at line 4696 of file game_lua_kernel.cpp.
|
private |
Definition at line 4708 of file game_lua_kernel.cpp.
|
private |
Definition at line 4692 of file game_lua_kernel.cpp.
|
friend |
Definition at line 72 of file game_lua_kernel.hpp.
|
private |
Definition at line 61 of file game_lua_kernel.hpp.
Referenced by clear_wml_event(), game_lua_kernel(), run_wml_event(), and save_wml_event().
|
private |
Definition at line 50 of file game_lua_kernel.hpp.
Referenced by set_game_display().
|
private |
Definition at line 51 of file game_lua_kernel.hpp.
|
private |
Definition at line 62 of file game_lua_kernel.hpp.
|
private |
Definition at line 60 of file game_lua_kernel.hpp.
Referenced by initialize().
int game_lua_kernel::map_locked_ |
A value != 0 means that the shouldn't remove any units from the map, usually because we are currently operating on a unit& and removing it might cause memory corruptions note that we don't check for the dtor of lua owned units because we assume that we operate on such a unit that the lua function that invoked the operation on that unit (like wesnoth.units.add_modification, wesnoth.units.matches ..) have a local copy of that lua_unit* userdata in its stack that prevents it from being collected.
Definition at line 206 of file game_lua_kernel.hpp.
Referenced by map_locker::map_locker(), and map_locker::~map_locker().
|
private |
Definition at line 52 of file game_lua_kernel.hpp.
Referenced by game_lua_kernel().
|
staticprivate |
Definition at line 70 of file game_lua_kernel.hpp.
|
staticprivate |
Definition at line 69 of file game_lua_kernel.hpp.
|
private |
Definition at line 64 of file game_lua_kernel.hpp.
Referenced by game_lua_kernel(), run_event(), run_wml_action(), and run_wml_event().
|
private |
Definition at line 53 of file game_lua_kernel.hpp.