The Battle for Wesnoth  1.15.2+dev
Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
game_lua_kernel Class Reference

#include <game_lua_kernel.hpp>

Inheritance diagram for game_lua_kernel:
Inheritance graph

Public Member Functions

game_boardboard ()
 
std::vector< team > & teams ()
 
const gamemapmap () const
 
game_displayget_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, int nArgs)
 Runs a script from a filter. More...
 
bool run_wml_conditional (const std::string &, const vconfig &)
 Evaluates a WML conidition. 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_contextcreate_lua_ai_context (char const *code, ai::engine_lua *engine)
 
ai::lua_ai_action_handlercreate_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)
 
- 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)
 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 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_Stateget_state ()
 
void add_widget_definition (const std::string &type, const std::string &id)
 

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.add_modification, wesnoth.match_unit ..) have a local copy of that lua_unit* userdata in its stack that prevents it from being collected. More...
 

Private Member Functions

unit_mapunits ()
 
game_datagamedata ()
 
tod_managertod_man ()
 
const game_events::queued_eventget_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_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_get_side_variable (lua_State *L)
 Gets a side specific WML variable. More...
 
int intf_set_variable (lua_State *L)
 Sets a WML variable. More...
 
int intf_set_side_variable (lua_State *L)
 Gets a side specific 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 intf_get_terrain (lua_State *L)
 Gets a terrain code. More...
 
int intf_set_terrain (lua_State *L)
 Sets a terrain code. More...
 
int intf_terrain_mask (lua_State *L)
 Reaplces part of the map. More...
 
int intf_get_terrain_info (lua_State *L)
 Gets details about a terrain. More...
 
int intf_get_time_of_day (lua_State *L)
 Gets time of day information. More...
 
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_map_size (lua_State *L)
 Returns the map size. 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 intf_get_starting_location (lua_State *L)
 Returns the starting position of a side. 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_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 intf_end_level (lua_State *)
 
int impl_end_level_data_set (lua_State *)
 
int intf_get_end_level_data (lua_State *)
 
int intf_end_turn (lua_State *)
 
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_cost_map (lua_State *L)
 Is called with one or more units and builds a cost 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_open_help (lua_State *L)
 
int intf_play_sound (lua_State *L)
 Plays a sound, possibly repeated. More...
 
int intf_print (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_set_menu_item (lua_State *L)
 
int intf_set_next_scenario (lua_State *L)
 
int intf_shroud_op (lua_State *L, bool place_shroud)
 
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_hex (lua_State *L)
 
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_get_villages (lua_State *L)
 Gets all the villages matching a given filter, or all the villages on the map if no filter is given. 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_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...
 
int intf_add_event (lua_State *L)
 Adding new events. More...
 
int intf_remove_event (lua_State *L)
 
int intf_color_adjust (lua_State *L)
 
int intf_delay (lua_State *L)
 Delays engine for a while. More...
 
int intf_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 intf_set_time_of_day (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_remove_sound_source (lua_State *L)
 Removes a sound source by its ID Arg 1: sound source ID. More...
 
int intf_add_sound_source (lua_State *L)
 Add a new sound source Arg 1: Table containing keyword arguments. More...
 
int intf_get_sound_source (lua_State *L)
 Get an existing sound source Arg 1: The sound source ID Return: Config of sound source info, or nil if it didn't exist This is a copy of the sound source info, so you need to call add_sound_source again after changing it. 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 config &game_config)
 

Private Attributes

game_displaygame_display_
 
game_stategame_state_
 
play_controllerplay_controller_
 
reportsreports_
 
config level_lua_
 
std::stack< game_events::queued_event const *> queued_events_
 

Static Private Attributes

static std::vector< configpreload_scripts
 
static config preload_config
 

Friends

class game_config_manager
 

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...
 
int intf_show_lua_console (lua_State *L)
 
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 Protected Member Functions inherited from lua_kernel_base
static bool protected_call (lua_State *L, int nArgs, int nRets, error_handler)
 
- Protected Attributes inherited from lua_kernel_base
lua_StatemState
 
command_log cmd_log_
 

Detailed Description

Definition at line 46 of file game_lua_kernel.hpp.

Constructor & Destructor Documentation

◆ game_lua_kernel()

game_lua_kernel::game_lua_kernel ( game_state gs,
play_controller pc,
reports reports_object 
)

Definition at line 4127 of file game_lua_kernel.cpp.

References unit::builtin_effects, lua_kernel_base::cmd_log_, 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_unit(), intf_debug_ai(), intf_do_unsynced(), intf_eval_conditional(), intf_get_era(), intf_get_traits(), intf_get_viewing_side(), intf_invoke_synced_command(), intf_modify_ai(), intf_modify_ai_old(), intf_remove_modifications(), intf_set_music(), intf_sound_volume(), intf_switch_ai(), intf_synchronize_choice(), intf_synchronize_choices(), intf_transform_unit(), intf_unit_defense(), intf_unit_jamming_cost(), intf_unit_movement_cost(), intf_unit_resistance(), intf_unit_vision_cost(), lua_createtable(), lua_getglobal(), lua_istable, lua_newtable, lua_newuserdata(), lua_pop, lua_pushcfunction, lua_pushstring(), lua_rawset(), lua_setfield(), lua_setglobal(), lua_setmetatable(), lua_settop(), luaL_setfuncs(), luaW_getglobal(), lua_kernel_base::mState, play_controller_, push_builtin_effect(), push_locations_table(), queued_events_, lua_units::register_attacks_metatables(), lua_race::register_metatable(), lua_unit_type::register_metatable(), lua_team::register_metatable(), 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().

Member Function Documentation

◆ apply_effect()

std::string game_lua_kernel::apply_effect ( const std::string &  name,
unit u,
const config cfg,
bool  need_apply 
)

◆ board()

game_board & game_lua_kernel::board ( )

Definition at line 4098 of file game_lua_kernel.cpp.

◆ cfun_builtin_effect()

int game_lua_kernel::cfun_builtin_effect ( lua_State L)
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 4592 of file game_lua_kernel.cpp.

References unit::apply_builtin_effect(), unit::describe_builtin_effect(), lua_pushstring(), lua_tostring, lua_upvalueindex, luaW_checkconfig(), luaW_checkunit(), and luaW_toboolean().

◆ cfun_wml_action()

int game_lua_kernel::cfun_wml_action ( lua_State L)
private

Executes its upvalue as a wml action.

Definition at line 4642 of file game_lua_kernel.cpp.

References get_event_info(), h, lua_touserdata(), lua_upvalueindex, and luaW_checkvconfig().

◆ create_lua_ai_action_handler()

ai::lua_ai_action_handler * game_lua_kernel::create_lua_ai_action_handler ( char const *  code,
ai::lua_ai_context context 
)

◆ create_lua_ai_context()

ai::lua_ai_context * game_lua_kernel::create_lua_ai_context ( char const *  code,
ai::engine_lua engine 
)

Definition at line 4874 of file game_lua_kernel.cpp.

References ai::lua_ai_context::create(), and lua_kernel_base::mState.

◆ custom_command()

void game_lua_kernel::custom_command ( const std::string &  name,
const config cfg 
)

◆ extract_preload_scripts()

void game_lua_kernel::extract_preload_scripts ( const config game_config)
staticprivate

Definition at line 174 of file game_lua_kernel.cpp.

References config::child(), and config::child_range().

Referenced by game_config_manager::load_game_config().

◆ gamedata()

game_data & game_lua_kernel::gamedata ( )
private

Definition at line 4114 of file game_lua_kernel.cpp.

◆ get_display()

game_display* game_lua_kernel::get_display ( ) const
inline

Definition at line 186 of file game_lua_kernel.hpp.

◆ get_event_info()

const game_events::queued_event & game_lua_kernel::get_event_info ( )
private

Definition at line 4122 of file game_lua_kernel.cpp.

Referenced by cfun_wml_action().

◆ get_sides_vector()

std::vector< int > game_lua_kernel::get_sides_vector ( const vconfig cfg)
private

Gets a vector of sides from side= attribute in a given config node.

Promotes consistent behavior.

Definition at line 201 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.

◆ impl_current_get()

int game_lua_kernel::impl_current_get ( lua_State L)
private

◆ impl_end_level_data_set()

int game_lua_kernel::impl_end_level_data_set ( lua_State L)
private

◆ impl_game_config_get()

int game_lua_kernel::impl_game_config_get ( lua_State L)
overrideprivatevirtual

◆ impl_game_config_set()

int game_lua_kernel::impl_game_config_set ( lua_State L)
overrideprivatevirtual

◆ impl_run_animation()

int game_lua_kernel::impl_run_animation ( lua_State L)
private

◆ impl_theme_item()

int game_lua_kernel::impl_theme_item ( lua_State L,
std::string  name 
)
private

Executes its upvalue as a theme item generator.

Definition at line 3818 of file game_lua_kernel.cpp.

References luaW_pushconfig().

Referenced by impl_theme_items_get().

◆ impl_theme_items_get()

int game_lua_kernel::impl_theme_items_get ( lua_State L)
private

Creates a field of the theme_items table and returns it (__index metamethod).

Definition at line 3828 of file game_lua_kernel.cpp.

References impl_theme_item(), lua_pushvalue(), lua_rawset(), luaL_checkstring, and lua_cpp::push_closure().

◆ impl_theme_items_set()

int game_lua_kernel::impl_theme_items_set ( lua_State L)
private

Sets a field of the theme_items table (__newindex metamethod).

Definition at line 3842 of file game_lua_kernel.cpp.

References lua_pushvalue(), lua_rawset(), and luaL_checkstring.

◆ initialize()

void game_lua_kernel::initialize ( const config level)

◆ intf_add_event()

int game_lua_kernel::intf_add_event ( lua_State L)
private

◆ intf_add_sound_source()

int game_lua_kernel::intf_add_sound_source ( lua_State L)
private

Add a new sound source Arg 1: Table containing keyword arguments.

Definition at line 3937 of file game_lua_kernel.cpp.

References soundsource::manager::add(), config::debug(), ERR_LUA, luaW_checkconfig(), and soundsource::manager::update().

◆ intf_add_tile_overlay()

int game_lua_kernel::intf_add_tile_overlay ( lua_State L)
private

Adds an overlay on a tile.

  • Arg 1: location.
  • Arg 2: WML table.

Definition at line 3309 of file game_lua_kernel.cpp.

References vconfig::child(), side_filter::get_teams(), utils::join(), luaW_checklocation(), luaW_checkvconfig(), and vconfig::null().

◆ intf_add_time_area()

int game_lua_kernel::intf_add_time_area ( lua_State L)
private

Adding new time_areas dynamically with Standard Location Filters.

Definition at line 3689 of file game_lua_kernel.cpp.

References vconfig::get_parsed_config(), LOG_LUA, log_scope, and luaW_checkvconfig().

◆ intf_allow_end_turn()

int game_lua_kernel::intf_allow_end_turn ( lua_State L)
private

Allow undo sets the flag saying whether the event has mutated the game to false.

Definition at line 3655 of file game_lua_kernel.cpp.

References resources::gamedata, luaW_iststring(), luaW_toboolean(), luaW_totstring(), and game_data::set_allow_end_turn().

◆ intf_allow_undo()

int game_lua_kernel::intf_allow_undo ( lua_State L)
private

Allow undo sets the flag saying whether the event has mutated the game to false.

Definition at line 3671 of file game_lua_kernel.cpp.

References lua_isboolean, and luaW_toboolean().

◆ intf_animate_unit()

int game_lua_kernel::intf_animate_unit ( lua_State )
private

◆ intf_cancel_action()

int game_lua_kernel::intf_cancel_action ( lua_State )
private

Definition at line 3682 of file game_lua_kernel.cpp.

◆ intf_clear_menu_item()

int game_lua_kernel::intf_clear_menu_item ( lua_State L)
private

Definition at line 827 of file game_lua_kernel.cpp.

References luaL_checkstring, utils::split(), utils::STRIP_SPACES, and WRN_LUA.

◆ intf_clear_messages()

int game_lua_kernel::intf_clear_messages ( lua_State )
private

Removes all messages from the chat window.

Definition at line 1570 of file game_lua_kernel.cpp.

◆ intf_color_adjust()

int game_lua_kernel::intf_color_adjust ( lua_State L)
private

Definition at line 3396 of file game_lua_kernel.cpp.

References luaW_checkvconfig().

◆ intf_create_animator()

int game_lua_kernel::intf_create_animator ( lua_State L)
private

◆ intf_delay()

int game_lua_kernel::intf_delay ( lua_State L)
private

Delays engine for a while.

  • Arg 1: integer.
  • Arg 2: boolean (optional).

Definition at line 3413 of file game_lua_kernel.cpp.

References CVideo::delay(), resources::gamedata, game_data::INITIAL, luaL_checkinteger(), luaW_toboolean(), game_data::PRELOAD, and game_data::PRESTART.

◆ intf_deselect_hex()

int game_lua_kernel::intf_deselect_hex ( lua_State L)
private

Deselects any highlighted hex on the map.

No arguments or return values

Definition at line 2769 of file game_lua_kernel.cpp.

References map_location::null_location().

◆ intf_end_level()

int game_lua_kernel::intf_end_level ( lua_State L)
private

◆ intf_end_turn()

int game_lua_kernel::intf_end_turn ( lua_State L)
private

◆ intf_erase_unit()

int game_lua_kernel::intf_erase_unit ( lua_State L)
private

◆ intf_extract_unit()

int game_lua_kernel::intf_extract_unit ( lua_State L)
private

Extracts a unit from the map or a recall list and gives it to Lua.

  • Arg 1: unit userdata.

Definition at line 2310 of file game_lua_kernel.cpp.

References recall_list_manager::erase_if_matches_id(), luaL_error(), luaW_checkunit_ref(), team::recall_list(), and t.

◆ intf_find_cost_map()

int game_lua_kernel::intf_find_cost_map ( lua_State L)
private

Is called with one or more units and builds a cost map.

  • Arg 1: source location. (Or Arg 1: unit. Or Arg 1: table containing a filter)
  • Arg 2: optional array of tables with 4 elements (coordinates + side + unit type string)
  • Arg 3: optional table (optional fields: ignore_units, ignore_teleport, viewing_side, debug).
  • Arg 4: optional table: standard location filter.
  • Ret 1: array of triples (coordinates + array of tuples(summed cost + reach counter)).

Definition at line 1946 of file game_lua_kernel.cpp.

References pathfind::full_cost_map::add_unit(), debug, resources::fake_units, unit_type_data::find(), pathfind::full_cost_map::get_pair_at(), i, intf_find_cost_map_helper(), load_fake_units(), lua_createtable(), lua_isnil, lua_istable, lua_pop, lua_pushinteger(), lua_pushstring(), lua_rawget(), lua_rawseti(), luaL_argerror(), luaL_checkinteger(), luaW_checklocation(), luaW_toboolean(), luaW_tounit(), luaW_tovconfig(), vconfig::null(), s, utf8::size(), vconfig::unconstructed_vconfig(), unit_types, and unit_map::iterator_base< iter_types >::valid().

◆ intf_find_path()

int game_lua_kernel::intf_find_path ( lua_State L)
private

Finds a path between two locations.

  • Arg 1: source location. (Or Arg 1: unit.)
  • Arg 2: destination.
  • Arg 3: optional cost function or table (optional fields: ignore_units, ignore_teleport, max_cost, viewing_side).
  • Ret 1: array of pairs containing path steps.
  • Ret 2: path cost.

Definition at line 1706 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::h(), i, lua_createtable(), lua_gettop(), lua_isfunction, lua_isnil, lua_istable, lua_isuserdata(), lua_pop, lua_pushinteger(), lua_pushstring(), lua_rawget(), lua_rawseti(), luaL_argerror(), luaL_checkinteger(), luaW_checklocation(), luaW_checkunit(), pathfind::plain_route::move_cost, unit::side(), utf8::size(), pathfind::plain_route::steps, unit_map::iterator_base< iter_types >::valid(), and gamemap::w().

◆ intf_find_reach()

int game_lua_kernel::intf_find_reach ( lua_State L)
private

Finds all the locations reachable by a unit.

  • Arg 1: source location OR unit.
  • Arg 2: optional table (optional fields: ignore_units, ignore_teleport, additional_turns, viewing_side).
  • Ret 1: array of triples (coordinates + remaining movement).

Definition at line 1815 of file game_lua_kernel.cpp.

References pathfind::paths::step::curr, pathfind::paths::destinations, unit_map::iterator_base< iter_types >::get_shared_ptr(), i, lua_createtable(), lua_isnil, lua_istable, lua_isuserdata(), lua_pop, lua_pushinteger(), lua_pushstring(), lua_rawget(), lua_rawseti(), lua_tointeger, luaL_argerror(), luaL_checkinteger(), luaW_checklocation(), luaW_checkunit(), luaW_toboolean(), 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().

◆ intf_find_vacant_tile()

int game_lua_kernel::intf_find_vacant_tile ( lua_State L)
private

Finds a vacant tile.

  • Arg 1: location.
  • Arg 2: optional unit for checking movement type.
  • Rets 1,2: location.

Definition at line 2342 of file game_lua_kernel.cpp.

References unit::create(), pathfind::find_vacant_tile(), lua_isnoneornil, lua_pushinteger(), luaW_checkconfig(), luaW_checklocation(), luaW_checkunit_ptr(), luaW_isunit(), pathfind::VACANT_ANY, map_location::valid(), map_location::wml_x(), and map_location::wml_y().

◆ intf_fire_event()

int game_lua_kernel::intf_fire_event ( lua_State L,
const bool  by_id 
)
private

Fires an event.

  • Arg 1: string containing the event name or id.
  • Arg 2: optional first location.
  • Arg 3: optional second location.
  • Arg 4: optional WML table used as the [weapon] tag.
  • Arg 5: optional WML table used as the [second_weapon] tag.
  • Ret 1: boolean indicating whether the event was processed or not.

Definition at line 687 of file game_lua_kernel.cpp.

References config::add_child(), b, lua_isnoneornil, lua_pushboolean(), luaL_checkstring, luaW_checkconfig(), and luaW_tolocation().

◆ intf_fire_wml_menu_item()

int game_lua_kernel::intf_fire_wml_menu_item ( lua_State L)
private

Fires a wml menu item.

  • Arg 1: id of the item. it is not possible to fire items that don't have ids with this function.
  • Arg 2: optional first location.
  • Ret 1: boolean, true indicating that the event was fired successfully

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 735 of file game_lua_kernel.cpp.

References b, resources::gamedata, lua_pushboolean(), luaL_checkstring, and luaW_checklocation().

◆ intf_float_label()

int game_lua_kernel::intf_float_label ( lua_State L)
private

Floats some text on the map.

  • Arg 1: location.
  • Arg 2: string.
  • Arg 3: color.

Definition at line 2371 of file game_lua_kernel.cpp.

References color_t::from_rgb_string(), font::LABEL_COLOR, lua_isnoneornil, luaL_checkstring, luaW_checklocation(), and luaW_checktstring().

◆ intf_gamestate_inspector()

int game_lua_kernel::intf_gamestate_inspector ( lua_State L)
private

◆ intf_get_all_vars()

int game_lua_kernel::intf_get_all_vars ( lua_State L)
private

Gets all the WML variables currently set.

  • Ret 1: WML table

Definition at line 3856 of file game_lua_kernel.cpp.

References resources::gamedata, and luaW_pushconfig().

◆ intf_get_displayed_unit()

int game_lua_kernel::intf_get_displayed_unit ( lua_State L)
private

Gets the unit displayed in the sidebar.

  • Ret 1: full userdata with __index pointing to impl_unit_get and __newindex pointing to impl_unit_set.

Definition at line 535 of file game_lua_kernel.cpp.

References luaW_pushunit(), and unit_map::iterator_base< iter_types >::valid().

◆ intf_get_end_level_data()

int game_lua_kernel::intf_get_end_level_data ( lua_State L)
private

◆ intf_get_fog_or_shroud()

int game_lua_kernel::intf_get_fog_or_shroud ( lua_State L,
bool  fog 
)
private

◆ intf_get_locations()

int game_lua_kernel::intf_get_locations ( lua_State L)
private

Gets all the locations matching a given filter.

  • Arg 1: WML table.
  • Arg 2: Optional reference unit (teleport_unit)
  • Ret 1: array of integer pairs.

Definition at line 2952 of file game_lua_kernel.cpp.

References i, lua_createtable(), lua_pushinteger(), lua_rawseti(), luaW_checkvconfig(), luaW_isunit(), and luaW_tounit().

◆ intf_get_map_size()

int game_lua_kernel::intf_get_map_size ( lua_State L)
private

Returns the map size.

  • Ret 1: width.
  • Ret 2: height.
  • Ret 3: border size.

Definition at line 1298 of file game_lua_kernel.cpp.

References gamemap::border_size(), gamemap::h(), lua_pushinteger(), and gamemap::w().

◆ intf_get_mouseover_tile()

int game_lua_kernel::intf_get_mouseover_tile ( lua_State L)
private

Returns the currently overed tile.

  • Ret 1: x.
  • Ret 2: y.

Definition at line 1312 of file game_lua_kernel.cpp.

References lua_pushinteger(), map_location::wml_x(), and map_location::wml_y().

◆ intf_get_recall_units()

int game_lua_kernel::intf_get_recall_units ( lua_State L)
private

Gets the numeric ids of all the units matching a given filter on the recall lists.

  • Arg 1: optional table containing a filter
  • Ret 1: table containing full userdata with __index pointing to impl_unit_get and __newindex pointing to impl_unit_set.

Definition at line 649 of file game_lua_kernel.cpp.

References i, lua_newtable, lua_rawseti(), lua_settop(), luaW_checkvconfig(), luaW_pushunit(), vconfig::null(), s, and t.

◆ intf_get_selected_tile()

int game_lua_kernel::intf_get_selected_tile ( lua_State L)
private

Returns the currently selected tile.

  • Ret 1: x.
  • Ret 2: y.

Definition at line 1330 of file game_lua_kernel.cpp.

References lua_pushinteger(), map_location::wml_x(), and map_location::wml_y().

◆ intf_get_side_variable()

int game_lua_kernel::intf_get_side_variable ( lua_State L)
private

Gets a side specific WML variable.

  • Arg 1: integer side number.
  • Arg 2: string containing the variable name.
  • Ret 1: value of the variable, if any.

Definition at line 765 of file game_lua_kernel.cpp.

References luaL_argerror(), luaL_checkinteger(), luaL_checkstring, luaW_pushvariable(), and utf8::size().

◆ intf_get_sides()

int game_lua_kernel::intf_get_sides ( lua_State L)
private

Returns a proxy table array for all sides matching the given SSF.

  • Arg 1: SSF
  • Ret 1: proxy table array

Definition at line 3159 of file game_lua_kernel.cpp.

References side_filter::get_teams(), utf8::index(), LOG_LUA, lua_createtable(), lua_rawseti(), lua_settop(), luaW_checkvconfig(), luaW_pushteam(), and vconfig::null().

◆ intf_get_sound_source()

int game_lua_kernel::intf_get_sound_source ( lua_State L)
private

Get an existing sound source Arg 1: The sound source ID Return: Config of sound source info, or nil if it didn't exist This is a copy of the sound source info, so you need to call add_sound_source again after changing it.

Definition at line 3960 of file game_lua_kernel.cpp.

References config::empty(), soundsource::manager::get(), luaL_checkstring, and luaW_pushconfig().

◆ intf_get_starting_location()

int game_lua_kernel::intf_get_starting_location ( lua_State L)
private

Returns the starting position of a side.

Arg 1: side number Ret 1: table with unnamed indices holding wml coordinates x and y

Definition at line 1348 of file game_lua_kernel.cpp.

References luaL_argerror(), luaL_checkinteger(), luaW_pushlocation(), and utf8::size().

◆ intf_get_terrain()

int game_lua_kernel::intf_get_terrain ( lua_State L)
private

Gets a terrain code.

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

Definition at line 975 of file game_lua_kernel.cpp.

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

◆ intf_get_terrain_info()

int game_lua_kernel::intf_get_terrain_info ( lua_State L)
private

◆ intf_get_time_of_day()

int game_lua_kernel::intf_get_time_of_day ( lua_State L)
private

◆ intf_get_unit()

int game_lua_kernel::intf_get_unit ( lua_State L)
private

Gets the unit at the given location or with the given id.

  • Arg 1: location OR
  • Arg 1: string ID
  • Ret 1: full userdata with __index pointing to impl_unit_get and __newindex pointing to impl_unit_set.

Definition at line 506 of file game_lua_kernel.cpp.

References lua_isnumber(), lua_isstring(), luaL_argerror(), luaL_checkstring, luaW_pushunit(), luaW_tolocation(), and unit_map::iterator_base< iter_types >::valid().

◆ intf_get_units()

int game_lua_kernel::intf_get_units ( lua_State L)
private

Gets all the units matching a given filter.

  • Arg 1: optional table containing a filter
  • Arg 2: optional location (to find all units that would match on that location) OR unit (to find all units that would match adjacent to that unit)
  • Ret 1: table containing full userdata with __index pointing to impl_unit_get and __newindex pointing to impl_unit_set.

Definition at line 559 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, lua_isnoneornil, lua_newtable, lua_rawseti(), lua_settop(), luaL_argerror(), luaW_checkvconfig(), luaW_pushunit(), luaW_tolocation(), luaW_tounit(), and map_location::valid().

◆ intf_get_variable()

int game_lua_kernel::intf_get_variable ( lua_State L)
private

Gets a WML variable.

  • Arg 1: string containing the variable name.
  • Arg 2: optional bool indicating if tables for containers should be left empty.
  • Ret 1: value of the variable, if any.

Definition at line 752 of file game_lua_kernel.cpp.

References resources::gamedata, game_data::get_variable_access_read(), luaL_checkstring, and luaW_pushvariable().

◆ intf_get_village_owner()

int game_lua_kernel::intf_get_village_owner ( lua_State L)
private

Gets the side of a village owner.

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

Definition at line 1221 of file game_lua_kernel.cpp.

References lua_pushinteger(), and luaW_checklocation().

◆ intf_get_villages()

int game_lua_kernel::intf_get_villages ( lua_State L)
private

Gets all the villages matching a given filter, or all the villages on the map if no filter is given.

  • Arg 1: WML table (optional).
  • Ret 1: array of integer pairs.

Definition at line 2985 of file game_lua_kernel.cpp.

References i, lua_createtable(), lua_newtable, lua_pushinteger(), lua_rawseti(), and luaW_checkvconfig().

◆ intf_heal_unit()

int game_lua_kernel::intf_heal_unit ( lua_State L)
private

◆ intf_highlight_hex()

int game_lua_kernel::intf_highlight_hex ( lua_State L)
private

Highlights the given location on the map.

  • Arg 1: location.

Definition at line 915 of file game_lua_kernel.cpp.

References luaL_argerror(), and luaW_checklocation().

◆ intf_is_enemy()

int game_lua_kernel::intf_is_enemy ( lua_State L)
private

Returns whether the first side is an enemy of the second one.

  • Args 1,2: side numbers.
  • Ret 1: boolean.

Definition at line 934 of file game_lua_kernel.cpp.

References lua_pushboolean(), luaL_checkinteger(), and utf8::size().

◆ intf_is_skipping_messages()

int game_lua_kernel::intf_is_skipping_messages ( lua_State L)
private

Return true if a replay is in progress but the player has chosen to skip it.

Definition at line 2781 of file game_lua_kernel.cpp.

References lua_pushboolean().

◆ intf_label()

int game_lua_kernel::intf_label ( lua_State L)
private

◆ intf_lock_view()

int game_lua_kernel::intf_lock_view ( lua_State L)
private

Sets whether gamemap scrolling is disabled for the user.

  • Arg 1: boolean, specifying the new locked/unlocked status.

Definition at line 961 of file game_lua_kernel.cpp.

References luaW_toboolean().

◆ intf_log()

int game_lua_kernel::intf_log ( lua_State L)
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 3981 of file game_lua_kernel.cpp.

References lua_isstring(), luaL_checkstring, luaW_toboolean(), wfl::msg(), and lg::wml_error().

◆ intf_log_replay()

int game_lua_kernel::intf_log_replay ( lua_State L)
private

◆ intf_match_location()

int game_lua_kernel::intf_match_location ( lua_State L)
private

Matches a location against the given filter.

  • Arg 1: location.
  • Arg 2: WML table.
  • Arg 3: Optional reference unit (teleport_unit)
  • Ret 1: boolean.

Definition at line 3016 of file game_lua_kernel.cpp.

References lua_pushboolean(), luaW_checklocation(), luaW_checkvconfig(), luaW_isunit(), luaW_tounit(), and vconfig::null().

◆ intf_match_side()

int game_lua_kernel::intf_match_side ( lua_State L)
private

Matches a side against the given filter.

  • Args 1: side number.
  • Arg 2: WML table.
  • Ret 1: boolean.

Definition at line 3044 of file game_lua_kernel.cpp.

References lua_pushboolean(), luaL_checkinteger(), luaW_checkvconfig(), luaW_toteam(), side_filter::match(), vconfig::null(), utf8::size(), and t.

◆ intf_match_unit()

int game_lua_kernel::intf_match_unit ( lua_State L)
private

Matches a unit against the given filter.

  • Arg 1: full userdata.
  • Arg 2: table containing a filter
  • Arg 3: optional location OR optional "adjacent" unit
  • Ret 1: boolean.

Definition at line 603 of file game_lua_kernel.cpp.

References recall_list_manager::find_index(), unit::get_location(), unit::id(), lua_pushboolean(), luaL_argerror(), 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.

◆ intf_message()

int game_lua_kernel::intf_message ( lua_State L)
private

Displays a message in the chat window and in the logs.

  • Arg 1: optional message header.
  • Arg 2 (or 1): message.

Definition at line 1528 of file game_lua_kernel.cpp.

References h, LOG_LUA, lua_isnone, and luaW_checktstring().

◆ intf_modify_ai_wml()

int game_lua_kernel::intf_modify_ai_wml ( lua_State L)
private

◆ intf_open_help()

int game_lua_kernel::intf_open_help ( lua_State L)
private

Definition at line 1542 of file game_lua_kernel.cpp.

References luaL_checkstring, and help::show_help().

◆ intf_play_sound()

int game_lua_kernel::intf_play_sound ( lua_State L)
private

Plays a sound, possibly repeated.

  • Arg 1: string.
  • Arg 2: optional integer.

Definition at line 2669 of file game_lua_kernel.cpp.

References lua_tointeger, luaL_checkstring, sound::play_sound(), and sound::SOUND_FX.

◆ intf_print()

int game_lua_kernel::intf_print ( lua_State L)
private

◆ intf_put_recall_unit()

int game_lua_kernel::intf_put_recall_unit ( lua_State L)
private

◆ intf_put_unit()

int game_lua_kernel::intf_put_unit ( lua_State L)
private

Places a unit on the map.

  • Arg 1: (optional) location.
  • Arg 2: Unit (WML table or proxy), or nothing/nil to delete. OR
  • Arg 1: Unit (WML table or proxy)
  • Arg 2: (optional) location
  • Arg 3: (optional) boolean

Definition at line 2167 of file game_lua_kernel.cpp.

References unit::create(), unit::get_location(), lua_unit::get_shared(), lua_isnoneornil, luaL_argerror(), luaL_error(), 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().

◆ intf_redraw()

int game_lua_kernel::intf_redraw ( lua_State L)
private

◆ intf_remove_event()

int game_lua_kernel::intf_remove_event ( lua_State L)
private

Definition at line 3390 of file game_lua_kernel.cpp.

References luaL_checkstring.

◆ intf_remove_sound_source()

int game_lua_kernel::intf_remove_sound_source ( lua_State L)
private

Removes a sound source by its ID Arg 1: sound source ID.

Definition at line 3925 of file game_lua_kernel.cpp.

References luaL_checkstring, and soundsource::manager::remove().

◆ intf_remove_tile_overlay()

int game_lua_kernel::intf_remove_tile_overlay ( lua_State L)
private

Removes an overlay from a tile.

  • Arg 1: location.
  • Arg 2: optional string.

Definition at line 3338 of file game_lua_kernel.cpp.

References lua_tostring, and luaW_checklocation().

◆ intf_remove_time_area()

int game_lua_kernel::intf_remove_time_area ( lua_State L)
private

Removing new time_areas dynamically with Standard Location Filters.

Definition at line 3706 of file game_lua_kernel.cpp.

References LOG_LUA, log_scope, and luaL_checkstring.

◆ intf_replace_schedule()

int game_lua_kernel::intf_replace_schedule ( lua_State l)
private

Replacing the current time of day schedule.

Definition at line 3718 of file game_lua_kernel.cpp.

References ERR_LUA, vconfig::get_children(), vconfig::get_parsed_config(), LOG_LUA, and luaW_checkvconfig().

◆ intf_scroll()

int game_lua_kernel::intf_scroll ( lua_State L)
private

◆ intf_scroll_to_tile()

int game_lua_kernel::intf_scroll_to_tile ( lua_State L)
private

Scrolls to given tile.

  • Arg 1: location.
  • Arg 2: boolean preventing scroll to fog.
  • Arg 3: boolean specifying whether to warp instantly.
  • Arg 4: boolean specifying whether to skip if already onscreen

Definition at line 2705 of file game_lua_kernel.cpp.

References luaW_checklocation(), luaW_toboolean(), display::ONSCREEN, display::ONSCREEN_WARP, display::SCROLL, and display::WARP.

◆ intf_select_hex()

int game_lua_kernel::intf_select_hex ( lua_State L)
private

◆ intf_select_unit()

int game_lua_kernel::intf_select_unit ( lua_State L)
private

Selects and highlights the given location on the map.

  • Arg 1: location.
  • Args 2,3: booleans

Definition at line 2747 of file game_lua_kernel.cpp.

References gui2::event::implementation::fire_event(), lua_isnoneornil, luaL_argerror(), luaW_checklocation(), luaW_toboolean(), and map_location::null_location().

◆ intf_set_end_campaign_credits()

int game_lua_kernel::intf_set_end_campaign_credits ( lua_State L)
private

◆ intf_set_end_campaign_text()

int game_lua_kernel::intf_set_end_campaign_text ( lua_State L)
private

◆ intf_set_menu_item()

int game_lua_kernel::intf_set_menu_item ( lua_State L)
private

Definition at line 821 of file game_lua_kernel.cpp.

References luaL_checkstring, and luaW_checkvconfig().

◆ intf_set_next_scenario()

int game_lua_kernel::intf_set_next_scenario ( lua_State L)
private

◆ intf_set_side_id()

int game_lua_kernel::intf_set_side_id ( lua_State L)
private

◆ intf_set_side_variable()

int game_lua_kernel::intf_set_side_variable ( lua_State L)
private

Gets a side specific WML variable.

  • Arg 1: integer side number.
  • Arg 2: string containing the variable name.
  • Arg 3: boolean/integer/string/table containing the value.

Definition at line 783 of file game_lua_kernel.cpp.

References lua_isnoneornil, luaL_argerror(), luaL_checkinteger(), luaL_checkstring, luaW_checkvariable(), and utf8::size().

◆ intf_set_terrain()

int game_lua_kernel::intf_set_terrain ( lua_State L)
private

Sets a terrain code.

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

Definition at line 992 of file game_lua_kernel.cpp.

References lua_isnil, lua_isnone, lua_isnoneornil, luaL_checkstring, luaW_checklocation(), and luaW_toboolean().

◆ intf_set_time_of_day()

int game_lua_kernel::intf_set_time_of_day ( lua_State L)
private

◆ intf_set_variable()

int game_lua_kernel::intf_set_variable ( lua_State L)
private

Sets a WML variable.

  • Arg 1: string containing the variable name.
  • Arg 2: boolean/integer/string/table containing the value.

Definition at line 808 of file game_lua_kernel.cpp.

References game_data::clear_variable(), resources::gamedata, game_data::get_variable_access_write(), lua_isnoneornil, luaL_argerror(), luaL_checkstring, and luaW_checkvariable().

◆ intf_set_village_owner()

int game_lua_kernel::intf_set_village_owner ( lua_State L)
private

Sets the owner of a village.

  • Arg 1: map location.
  • Arg 2: integer for the side or empty to remove ownership.

Definition at line 1238 of file game_lua_kernel.cpp.

References resources::gamedata, team::get_village(), team::lose_village(), lua_isnoneornil, luaL_checkinteger(), luaW_checklocation(), and luaW_toboolean().

◆ intf_shroud_op()

int game_lua_kernel::intf_shroud_op ( lua_State L,
bool  place_shroud 
)
private

◆ intf_simulate_combat()

int game_lua_kernel::intf_simulate_combat ( lua_State L)
private

Simulates a combat between two units.

  • Arg 1: attacker userdata.
  • Arg 2: optional weapon index.
  • Arg 3: defender userdata.
  • Arg 4: optional weapon index.
  • Ret 1: attacker results.
  • Ret 2: defender results.
  • Ret 3: info about the attacker weapon.
  • Ret 4: info about the defender weapon.

Definition at line 2615 of file game_lua_kernel.cpp.

References lua_isnumber(), lua_tointeger, luaL_argerror(), luaW_checkunit(), luaW_pushsimdata(), luaW_pushsimweapon(), and unit::shared_from_this().

◆ intf_skip_messages()

int game_lua_kernel::intf_skip_messages ( lua_State L)
private

Set whether to skip messages Arg 1 (optional) - boolean.

Definition at line 2795 of file game_lua_kernel.cpp.

References config::empty(), lua_isfunction, lua_isnone, lua_pushnumber(), lua_pushvalue(), luaW_pcall(), luaW_toboolean(), and luaW_toconfig().

◆ intf_teleport()

int game_lua_kernel::intf_teleport ( lua_State L)
private

◆ intf_terrain_mask()

int game_lua_kernel::intf_terrain_mask ( lua_State L)
private

Reaplces part of the map.

  • Arg 1: map location.
  • Arg 2: map data string.
  • Arg 3: table for optional named arguments
    • is_odd: boolen, if Arg2 has the odd mapo format (as if it was cut from a odd map location)
    • ignore_special_locations: boolean
    • rules: table of tables

Definition at line 1027 of file game_lua_kernel.cpp.

References terrain_type_data::BASE, terrain_type_data::BOTH, i, is_odd(), lua_istable, lua_pop, lua_rawgeti(), lua_rawlen(), luaL_argerror(), luaL_checkstring, luaW_checklocation(), luaW_tableget(), luaW_toboolean(), luaW_tostring(), terrain_type_data::OVERLAY, gamemap::read(), t_translation::read_list(), t, and gui2::terrain.

◆ intf_toggle_fog()

int game_lua_kernel::intf_toggle_fog ( lua_State L,
const bool  clear 
)
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 4021 of file game_lua_kernel.cpp.

References team::add_fog_override(), team::clear_fog(), lua_isboolean, lua_isnumber(), lua_istable, lua_tonumber, luaW_toboolean(), team::refog(), team::remove_fog_override(), and t.

◆ intf_unit_ability()

int game_lua_kernel::intf_unit_ability ( lua_State L)
private

Returns true if the unit has the given ability enabled.

  • Arg 1: unit userdata.
  • Arg 2: string.
  • Ret 1: boolean.

Definition at line 2502 of file game_lua_kernel.cpp.

References unit::get_ability_bool(), lua_pushboolean(), luaL_checkstring, and luaW_checkunit().

◆ intf_view_locked()

int game_lua_kernel::intf_view_locked ( lua_State L)
private

Gets whether gamemap scrolling is disabled for the user.

  • Ret 1: boolean.

Definition at line 947 of file game_lua_kernel.cpp.

References lua_pushboolean().

◆ intf_zoom()

int game_lua_kernel::intf_zoom ( lua_State L)
private

◆ load_game()

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 4496 of file game_lua_kernel.cpp.

References config::all_children_range(), is_handled_file_tag(), lua_createtable(), lua_newtable, lua_pushstring(), lua_rawseti(), luaW_getglobal(), luaW_pcall(), luaW_pushconfig(), and lua_kernel_base::mState.

◆ log_error()

void game_lua_kernel::log_error ( char const *  msg,
char const *  context = "Lua error" 
)
overridevirtual

Error reporting mechanisms, used by virtual methods protected_call and load_string.

Reimplemented from lua_kernel_base.

Definition at line 183 of file game_lua_kernel.cpp.

References lua_kernel_base::log_error().

Referenced by run_filter(), and save_game().

◆ lua_chat()

void game_lua_kernel::lua_chat ( const std::string &  caption,
const std::string &  msg 
)
private

Definition at line 189 of file game_lua_kernel.cpp.

References events::chat_handler::MESSAGE_PUBLIC.

◆ map()

const gamemap & game_lua_kernel::map ( ) const

Definition at line 4110 of file game_lua_kernel.cpp.

◆ mouse_over_hex_callback()

void game_lua_kernel::mouse_over_hex_callback ( const map_location loc)

◆ my_name()

virtual std::string game_lua_kernel::my_name ( )
inlineoverridevirtual

User-visible name of the lua kernel that they are talking to.

Reimplemented from lua_kernel_base.

Definition at line 200 of file game_lua_kernel.hpp.

References preferences::custom_command(), game_config::images::level, and wfl::msg().

◆ push_builtin_effect()

void game_lua_kernel::push_builtin_effect ( )

Registers a function for use as an effect handler.

Definition at line 4617 of file game_lua_kernel.cpp.

References lua_gettop(), lua_newtable, lua_pushboolean(), lua_pushcclosure(), lua_pushstring(), lua_pushvalue(), lua_rawset(), lua_setmetatable(), and lua_kernel_base::mState.

Referenced by game_lua_kernel().

◆ put_unit_helper()

void game_lua_kernel::put_unit_helper ( const map_location loc)
private

Definition at line 2148 of file game_lua_kernel.cpp.

References resources::whiteboard.

◆ run_event()

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 4561 of file game_lua_kernel.cpp.

References dummy, lua_pushstring(), luaW_getglobal(), luaW_pcall(), lua_kernel_base::mState, game_events::queued_event::name, and queued_events_.

Referenced by game_events::wml_event_pump::operator()().

◆ run_filter() [1/3]

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 4768 of file game_lua_kernel.cpp.

References lua_pop, lua_pushvalue(), luaW_pushlocalunit(), and lua_kernel_base::mState.

Referenced by run_filter().

◆ run_filter() [2/3]

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 4758 of file game_lua_kernel.cpp.

References lua_pushinteger(), lua_kernel_base::mState, run_filter(), map_location::wml_x(), and map_location::wml_y().

◆ run_filter() [3/3]

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 4786 of file game_lua_kernel.cpp.

References b, log_error(), lua_insert, lua_pop, luaW_getglobal(), luaW_pcall(), luaW_toboolean(), lua_kernel_base::mState, game_config::path, utils::split(), and utils::STRIP_SPACES.

◆ run_wml_action()

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.

Returns
true if there is a handler for the command.
Note
cfg should be either volatile or long-lived since the Lua code may grab it for an arbitrary long time.

Definition at line 4707 of file game_lua_kernel.cpp.

References dummy, luaW_getglobal(), luaW_pcall(), luaW_pushvconfig(), lua_kernel_base::mState, and queued_events_.

Referenced by game_events::event_handler::handle_event(), and actions::undo_action::undo_action().

◆ run_wml_conditional()

bool game_lua_kernel::run_wml_conditional ( const std::string &  cmd,
const vconfig cfg 
)

Evaluates a WML conidition.

Returns
Whether the condition passed.
Note
cfg should be either volatile or long-lived since the Lua code may grab it for an arbitrarily long time.

Definition at line 4730 of file game_lua_kernel.cpp.

References b, lua_pop, luaW_getglobal(), luaW_pcall(), luaW_pushvconfig(), luaW_toboolean(), lua_kernel_base::mState, and lg::wml_error().

Referenced by game_events::builtin_conditions::variable_matches().

◆ save_game()

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 4523 of file game_lua_kernel.cpp.

References config::erase(), i, is_handled_file_tag(), log_error(), lua_pop, luaW_getglobal(), luaW_pcall(), luaW_toconfig(), lua_kernel_base::mState, config::ordered_begin(), config::ordered_end(), and config::splice_children().

◆ select_hex_callback()

void game_lua_kernel::select_hex_callback ( const map_location loc)

◆ set_game_display()

void game_lua_kernel::set_game_display ( game_display gd)

Definition at line 4450 of file game_lua_kernel.cpp.

References game_display_.

◆ set_wml_action()

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 4655 of file game_lua_kernel.cpp.

References lua_getglobal(), lua_pop, lua_pushcclosure(), lua_pushlightuserdata(), lua_pushstring(), lua_rawget(), lua_rawset(), and lua_kernel_base::mState.

Referenced by game_lua_kernel().

◆ set_wml_condition()

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 4687 of file game_lua_kernel.cpp.

References cfun_wml_condition(), lua_getglobal(), lua_pop, lua_pushcclosure(), lua_pushlightuserdata(), lua_pushstring(), lua_rawget(), lua_rawset(), and lua_kernel_base::mState.

Referenced by game_lua_kernel().

◆ synced_state()

std::string game_lua_kernel::synced_state ( )
private

◆ teams()

std::vector< team > & game_lua_kernel::teams ( )

Definition at line 4106 of file game_lua_kernel.cpp.

◆ tod_man()

tod_manager & game_lua_kernel::tod_man ( )
private

Definition at line 4118 of file game_lua_kernel.cpp.

◆ units()

unit_map & game_lua_kernel::units ( )
private

Definition at line 4102 of file game_lua_kernel.cpp.

Friends And Related Function Documentation

◆ game_config_manager

friend class game_config_manager
friend

Definition at line 68 of file game_lua_kernel.hpp.

Member Data Documentation

◆ game_display_

game_display* game_lua_kernel::game_display_
private

Definition at line 48 of file game_lua_kernel.hpp.

Referenced by set_game_display().

◆ game_state_

game_state& game_lua_kernel::game_state_
private

Definition at line 49 of file game_lua_kernel.hpp.

◆ level_lua_

config game_lua_kernel::level_lua_
private

Definition at line 58 of file game_lua_kernel.hpp.

Referenced by initialize().

◆ map_locked_

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.add_modification, wesnoth.match_unit ..) have a local copy of that lua_unit* userdata in its stack that prevents it from being collected.

Definition at line 195 of file game_lua_kernel.hpp.

Referenced by map_locker::map_locker(), and map_locker::~map_locker().

◆ play_controller_

play_controller& game_lua_kernel::play_controller_
private

Definition at line 50 of file game_lua_kernel.hpp.

Referenced by game_lua_kernel().

◆ preload_config

config game_lua_kernel::preload_config
staticprivate

Definition at line 66 of file game_lua_kernel.hpp.

◆ preload_scripts

std::vector< config > game_lua_kernel::preload_scripts
staticprivate

Definition at line 65 of file game_lua_kernel.hpp.

◆ queued_events_

std::stack<game_events::queued_event const * > game_lua_kernel::queued_events_
private

Definition at line 60 of file game_lua_kernel.hpp.

Referenced by game_lua_kernel(), run_event(), and run_wml_action().

◆ reports_

reports& game_lua_kernel::reports_
private

Definition at line 51 of file game_lua_kernel.hpp.


The documentation for this class was generated from the following files: