#include "config.hpp"
#include "variable_info.hpp"
#include "map/location.hpp"
#include <string>
#include <string_view>
#include <vector>
Go to the source code of this file.
Namespaces | |
lua_common | |
Macros | |
#define | return_tstring_attrib(name, accessor) |
#define | return_cstring_attrib(name, accessor) |
#define | return_string_attrib(name, accessor) |
#define | return_int_attrib(name, accessor) |
#define | return_float_attrib(name, accessor) |
#define | return_bool_attrib(name, accessor) |
#define | return_cfg_attrib(name, accessor) |
#define | return_cfgref_attrib(name, accessor) |
#define | return_vector_string_attrib(name, accessor) |
#define | modify_tstring_attrib(name, accessor) |
#define | modify_string_attrib(name, accessor) |
#define | modify_int_attrib(name, accessor) |
#define | modify_int_attrib_check_range(name, accessor, allowed_min, allowed_max) |
#define | modify_float_attrib(name, accessor) |
#define | modify_float_attrib_check_range(name, accessor, allowed_min, allowed_max) |
#define | modify_bool_attrib(name, accessor) |
#define | modify_cfg_attrib(name, accessor) |
#define | modify_vector_string_attrib(name, accessor) |
Functions | |
int | lua_common::intf_textdomain (lua_State *L) |
Creates an interface for gettext. More... | |
int | lua_common::intf_tovconfig (lua_State *L) |
Creates a vconfig containing the WML table. More... | |
std::string | lua_common::register_gettext_metatable (lua_State *L) |
Adds the gettext metatable. More... | |
std::string | lua_common::register_tstring_metatable (lua_State *L) |
Adds the tstring metatable. More... | |
std::string | lua_common::register_vconfig_metatable (lua_State *L) |
Adds the vconfig metatable. More... | |
void * | operator new (std::size_t sz, lua_State *L, int nuv=0) |
void | operator delete (void *p, lua_State *L, int nuv) |
bool | luaW_getmetafield (lua_State *L, int idx, const char *key) |
Like luaL_getmetafield, but returns false if key is an empty string or begins with two underscores. More... | |
void | luaW_pushvconfig (lua_State *L, const vconfig &cfg) |
Pushes a vconfig on the top of the stack. More... | |
void | luaW_pushtstring (lua_State *L, const t_string &v) |
Pushes a t_string on the top of the stack. More... | |
void | luaW_pushscalar (lua_State *L, const config::attribute_value &v) |
Converts an attribute value into a Lua object pushed at the top of the stack. More... | |
bool | luaW_toscalar (lua_State *L, int index, config::attribute_value &v) |
Converts the value at the top of the stack to an attribute value. More... | |
bool | luaW_totstring (lua_State *L, int index, t_string &str) |
Converts a scalar to a translatable string. More... | |
t_string | luaW_checktstring (lua_State *L, int index) |
Converts a scalar to a translatable string. More... | |
bool | luaW_iststring (lua_State *L, int index) |
void | luaW_filltable (lua_State *L, const config &cfg) |
Converts a config object to a Lua table. More... | |
void | luaW_pushlocation (lua_State *L, const map_location &loc) |
Converts a map location object to a Lua table pushed at the top of the stack. More... | |
bool | luaW_tolocation (lua_State *L, int index, map_location &loc) |
Converts an optional table or pair of integers to a map location object. More... | |
map_location | luaW_checklocation (lua_State *L, int index) |
Converts an optional table or pair of integers to a map location object. More... | |
void | luaW_pushconfig (lua_State *L, const config &cfg) |
Converts a config object to a Lua table pushed at the top of the stack. More... | |
bool | luaW_toconfig (lua_State *L, int index, config &cfg) |
Converts an optional table or vconfig to a config object. More... | |
config | luaW_checkconfig (lua_State *L, int index) |
Converts an optional table or vconfig to a config object. More... | |
bool | luaW_tovconfig (lua_State *L, int index, vconfig &vcfg) |
Gets an optional vconfig from either a table or a userdata. More... | |
vconfig | luaW_checkvconfig (lua_State *L, int index, bool allow_missing=false) |
Gets an optional vconfig from either a table or a userdata. More... | |
config | luaW_checkconfig (lua_State *L, int index, const vconfig *&vcfg) |
Like the two-argument version, but if it was a vconfig, also returns a pointer to that vconfig. More... | |
bool | luaW_getglobal (lua_State *L, const std::vector< std::string > &path) |
Pushes the value found by following the variadic names (char *), if the value is not nil. More... | |
template<typename... T> | |
bool | luaW_getglobal (lua_State *L, T... path) |
Pushes the value found by following the variadic names (char *), if the value is not nil. More... | |
bool | luaW_toboolean (lua_State *L, int n) |
bool | luaW_pushvariable (lua_State *L, variable_access_const &v) |
bool | luaW_checkvariable (lua_State *L, variable_access_create &v, int n) |
bool | luaW_tableget (lua_State *L, int index, const char *key) |
std::string_view | luaW_tostring (lua_State *L, int index) |
std::string_view | luaW_tostring_or_default (lua_State *L, int index, std::string_view def=std::string_view()) |
void | chat_message (const std::string &caption, const std::string &msg) |
Displays a message in the chat window. More... | |
bool | luaW_pcall (lua_State *L, int nArgs, int nRets, bool allow_wml_error=false) |
Calls a Lua function stored below its nArgs arguments at the top of the stack. More... | |
void | push_error_handler (lua_State *L) |
int | luaW_pcall_internal (lua_State *L, int nArgs, int nRets) |
int | luaW_type_error (lua_State *L, int narg, const char *tname) |
int | luaW_type_error (lua_State *L, int narg, const char *kpath, const char *tname) |
#define modify_bool_attrib | ( | name, | |
accessor | |||
) |
Definition at line 348 of file lua_common.hpp.
Referenced by game_lua_kernel::impl_end_level_data_set(), game_lua_kernel::impl_game_config_set(), and impl_track_set().
#define modify_cfg_attrib | ( | name, | |
accessor | |||
) |
Definition at line 357 of file lua_common.hpp.
Referenced by impl_unit_variables_set().
#define modify_float_attrib | ( | name, | |
accessor | |||
) |
Definition at line 329 of file lua_common.hpp.
#define modify_float_attrib_check_range | ( | name, | |
accessor, | |||
allowed_min, | |||
allowed_max | |||
) |
Definition at line 338 of file lua_common.hpp.
Referenced by impl_music_set().
#define modify_int_attrib | ( | name, | |
accessor | |||
) |
Definition at line 310 of file lua_common.hpp.
Referenced by game_lua_kernel::impl_game_config_set(), impl_track_set(), and impl_unit_attack_set().
#define modify_int_attrib_check_range | ( | name, | |
accessor, | |||
allowed_min, | |||
allowed_max | |||
) |
Definition at line 319 of file lua_common.hpp.
Referenced by impl_music_set().
#define modify_string_attrib | ( | name, | |
accessor | |||
) |
Definition at line 301 of file lua_common.hpp.
Referenced by game_lua_kernel::impl_end_level_data_set(), game_lua_kernel::impl_game_config_set(), impl_track_set(), and impl_unit_attack_set().
#define modify_tstring_attrib | ( | name, | |
accessor | |||
) |
Definition at line 292 of file lua_common.hpp.
Referenced by impl_unit_attack_set().
#define modify_vector_string_attrib | ( | name, | |
accessor | |||
) |
Definition at line 366 of file lua_common.hpp.
Referenced by game_lua_kernel::impl_game_config_set().
#define return_bool_attrib | ( | name, | |
accessor | |||
) |
Definition at line 251 of file lua_common.hpp.
Referenced by game_lua_kernel::impl_current_get(), impl_end_level_data_get(), game_lua_kernel::impl_game_config_get(), lua_kernel_base::impl_game_config_get(), impl_race_get(), impl_side_get(), impl_track_get(), and impl_unit_attack_get().
#define return_cfg_attrib | ( | name, | |
accessor | |||
) |
Definition at line 259 of file lua_common.hpp.
Referenced by impl_end_level_data_get(), impl_side_get(), and impl_track_get().
#define return_cfgref_attrib | ( | name, | |
accessor | |||
) |
Definition at line 269 of file lua_common.hpp.
Referenced by game_lua_kernel::impl_game_config_get(), impl_race_get(), impl_unit_attack_get(), impl_unit_type_get(), and impl_unit_variables_get().
#define return_cstring_attrib | ( | name, | |
accessor | |||
) |
Definition at line 218 of file lua_common.hpp.
Referenced by impl_end_level_data_get(), and impl_side_get().
#define return_float_attrib | ( | name, | |
accessor | |||
) |
Definition at line 243 of file lua_common.hpp.
Referenced by impl_music_get(), and impl_side_get().
#define return_int_attrib | ( | name, | |
accessor | |||
) |
Definition at line 235 of file lua_common.hpp.
Referenced by game_lua_kernel::impl_current_get(), game_lua_kernel::impl_game_config_get(), lua_kernel_base::impl_game_config_get(), impl_race_get(), impl_side_get(), impl_terrainmap_get(), impl_track_get(), impl_unit_attack_get(), and impl_unit_type_get().
#define return_string_attrib | ( | name, | |
accessor | |||
) |
Definition at line 226 of file lua_common.hpp.
Referenced by game_lua_kernel::impl_current_get(), impl_end_level_data_get(), game_lua_kernel::impl_game_config_get(), lua_kernel_base::impl_game_config_get(), impl_race_get(), impl_side_get(), impl_terrainmap_get(), impl_track_get(), impl_unit_attack_get(), and impl_unit_type_get().
#define return_tstring_attrib | ( | name, | |
accessor | |||
) |
Definition at line 210 of file lua_common.hpp.
Referenced by impl_race_get(), impl_side_get(), and impl_unit_type_get().
#define return_vector_string_attrib | ( | name, | |
accessor | |||
) |
Definition at line 277 of file lua_common.hpp.
Referenced by game_lua_kernel::impl_game_config_get(), and impl_unit_type_get().
void chat_message | ( | const std::string & | caption, |
const std::string & | msg | ||
) |
Displays a message in the chat window.
Definition at line 1001 of file lua_common.cpp.
References display_chat_manager::add_chat_message(), game_display::get_chat_manager(), game_display::get_singleton(), and events::chat_handler::MESSAGE_PUBLIC.
Referenced by luaW_getglobal(), and luaW_pcall().
Converts an optional table or vconfig to a config object.
Definition at line 822 of file lua_common.cpp.
References luaW_toconfig(), and luaW_type_error().
Referenced by game_lua_kernel::cfun_builtin_effect(), impl_context_backend(), impl_unit_attack_match(), impl_unit_attack_set(), impl_unit_attacks_set(), intf_add_modification(), game_lua_kernel::intf_add_sound_source(), lua_gui2::intf_add_widget_definition(), intf_append_ai(), lua_wml::intf_clone_wml(), intf_create_attack(), game_lua_kernel::intf_create_side(), intf_create_unit(), intf_default_generate(), intf_default_generate_height_map(), game_lua_kernel::intf_find_vacant_tile(), game_lua_kernel::intf_fire_event(), lua_stringx::intf_format(), intf_invoke_synced_command(), intf_modify_ai(), game_lua_kernel::intf_put_recall_unit(), game_lua_kernel::intf_put_unit(), intf_remove_modifications(), intf_set_dialog_canvas(), intf_set_music(), intf_show_dialog(), intf_switch_ai(), lua_wml::intf_wml_diff(), lua_wml::intf_wml_equal(), lua_wml::intf_wml_interpolate(), lua_wml::intf_wml_matches_filter(), lua_wml::intf_wml_merge(), lua_wml::intf_wml_patch(), lua_wml::intf_wml_tostring(), lua_check_impl::lua_check(), luaW_checkconfig(), lua_gui2::show_message_dialog(), and lua_gui2::show_story().
Like the two-argument version, but if it was a vconfig, also returns a pointer to that vconfig.
Definition at line 830 of file lua_common.cpp.
References luaL_testudata(), luaW_checkconfig(), p, and vconfigKey.
map_location luaW_checklocation | ( | lua_State * | L, |
int | index | ||
) |
Converts an optional table or pair of integers to a map location object.
Definition at line 725 of file lua_common.cpp.
References luaW_tolocation(), and luaW_type_error().
Referenced by ai::ai_attack(), ai::ai_move(), ai::ai_stopunit_select(), impl_slocs_set(), impl_terrainmap_iter(), impl_unit_set(), game_lua_kernel::intf_add_tile_overlay(), game_lua_kernel::intf_find_cost_map(), game_lua_kernel::intf_find_path(), game_lua_kernel::intf_find_reach(), game_lua_kernel::intf_find_vacant_tile(), game_lua_kernel::intf_fire_wml_menu_item(), game_lua_kernel::intf_float_label(), game_lua_kernel::intf_get_fog_or_shroud(), game_lua_kernel::intf_get_label(), game_lua_kernel::intf_get_village_owner(), game_lua_kernel::intf_highlight_hex(), game_lua_kernel::intf_match_location(), intf_on_board(), intf_on_border(), game_lua_kernel::intf_remove_tile_overlay(), game_lua_kernel::intf_scroll_to_tile(), game_lua_kernel::intf_select_hex(), game_lua_kernel::intf_select_unit(), game_lua_kernel::intf_set_village_owner(), game_lua_kernel::intf_teleport(), intf_terrain_mask(), intf_unit_resistance(), lua_check_impl::lua_check(), and luaW_to_locationset().
Converts a scalar to a translatable string.
Definition at line 623 of file lua_common.cpp.
References luaW_totstring(), and luaW_type_error().
Referenced by intf_deprecated_message(), game_lua_kernel::intf_float_label(), lua_stringx::intf_format(), lua_stringx::intf_format_list(), game_lua_kernel::intf_message(), intf_name_generator(), game_lua_kernel::intf_set_end_campaign_text(), lua_check_impl::lua_check(), lua_gui2::show_message_box(), lua_gui2::show_popup_dialog(), and lua_gui2::show_story().
bool luaW_checkvariable | ( | lua_State * | L, |
variable_access_create & | v, | ||
int | n | ||
) |
Definition at line 926 of file lua_common.cpp.
References variable_info< V >::as_container(), variable_info< V >::as_scalar(), config::clear(), variable_info< V >::get_error_message(), LUA_TBOOLEAN, LUA_TNUMBER, lua_tonumber, lua_tostring, LUA_TSTRING, LUA_TTABLE, LUA_TUSERDATA, lua_type(), lua_typename(), luaL_testudata(), luaW_toboolean(), luaW_toconfig(), luaW_type_error(), tstringKey, and WRN_LUA.
Referenced by impl_unit_variables_set(), game_lua_kernel::intf_set_variable(), and luaW_getglobal().
Gets an optional vconfig from either a table or a userdata.
L | the pointer to the lua interpreter. |
index | the location in the current lua execution stack to look at. |
allow_missing | true if missing values are allowed; the function then returns an unconstructed vconfig. |
Definition at line 866 of file lua_common.cpp.
References luaW_tovconfig(), luaW_type_error(), vconfig::null(), and vconfig::unconstructed_vconfig().
Referenced by game_lua_kernel::cfun_wml_action(), cfun_wml_condition(), lua_common::impl_vconfig_ipairs(), lua_common::impl_vconfig_ipairs_iter(), lua_common::impl_vconfig_pairs(), lua_common::impl_vconfig_pairs_iter(), game_lua_kernel::intf_add_event(), game_lua_kernel::intf_add_tile_overlay(), game_lua_kernel::intf_add_time_area(), game_lua_kernel::intf_color_adjust(), game_lua_kernel::intf_end_level(), intf_eval_conditional(), game_lua_kernel::intf_gamestate_inspector(), game_lua_kernel::intf_get_locations(), game_lua_kernel::intf_get_recall_units(), game_lua_kernel::intf_get_sides(), game_lua_kernel::intf_get_units(), game_lua_kernel::intf_get_villages(), game_lua_kernel::intf_label(), game_lua_kernel::intf_match_location(), game_lua_kernel::intf_match_side(), game_lua_kernel::intf_match_unit(), game_lua_kernel::intf_print(), game_lua_kernel::intf_redraw(), game_lua_kernel::intf_replace_schedule(), game_lua_kernel::intf_set_menu_item(), and lua_common::intf_tovconfig().
Converts a config object to a Lua table.
The destination table should be at the top of the stack on entry. It is still at the top on exit.
Definition at line 642 of file lua_common.cpp.
References config::all_children_range(), config::attribute_range(), lua_checkstack(), lua_createtable(), LUA_MINSTACK, lua_newtable, lua_pushstring(), lua_rawseti(), lua_setfield(), luaW_filltable(), and luaW_pushscalar().
Referenced by luaW_filltable(), luaW_pushconfig(), and luaW_pushvariable().
bool luaW_getglobal | ( | lua_State * | L, |
const std::vector< std::string > & | path | ||
) |
Pushes the value found by following the variadic names (char *), if the value is not nil.
Definition at line 874 of file lua_common.cpp.
References lua_isnil, lua_istable, lua_pop, lua_pushglobaltable, lua_pushlstring(), lua_rawget(), lua_remove, and s.
Referenced by game_lua_kernel::apply_effect(), game_lua_kernel::custom_command(), game_lua_kernel::game_lua_kernel(), impl_side_get(), lua_stringx::impl_str_index(), impl_terrainmap_get(), impl_warn(), lua_widget::impl_widget_get(), lua_kernel_base::interactive_run(), intf_invoke_synced_command(), game_lua_kernel::intf_scroll(), lua_kernel_base::load_core(), game_lua_kernel::load_game(), lua_kernel_base::lua_kernel_base(), luaW_getglobal(), mapgen_lua_kernel::mapgen_lua_kernel(), game_lua_kernel::mouse_over_hex_callback(), push_error_handler(), lua_units::register_attacks_metatables(), lua_common::register_tstring_metatable(), game_lua_kernel::run_event(), game_lua_kernel::run_filter(), game_lua_kernel::run_wml_action(), game_lua_kernel::run_wml_conditional(), game_lua_kernel::save_game(), game_lua_kernel::select_hex_callback(), and WIDGET_SETTER().
bool luaW_getglobal | ( | lua_State * | L, |
T... | path | ||
) |
Pushes the value found by following the variadic names (char *), if the value is not nil.
Definition at line 172 of file lua_common.hpp.
References chat_message(), utf8::index(), luaW_checkvariable(), luaW_getglobal(), luaW_pcall(), luaW_pcall_internal(), luaW_pushvariable(), luaW_tableget(), luaW_toboolean(), luaW_tostring(), luaW_tostring_or_default(), luaW_type_error(), wfl::msg(), n, game_config::path, and push_error_handler().
bool luaW_getmetafield | ( | lua_State * | L, |
int | idx, | ||
const char * | key | ||
) |
Like luaL_getmetafield, but returns false if key is an empty string or begins with two underscores.
Definition at line 512 of file lua_common.cpp.
References luaL_getmetafield(), and n.
Referenced by impl_animator_get(), impl_music_get(), impl_track_get(), and impl_unit_attack_get().
bool luaW_iststring | ( | lua_State * | L, |
int | index | ||
) |
Definition at line 631 of file lua_common.cpp.
References lua_isstring(), lua_isuserdata(), luaL_testudata(), and tstringKey.
Referenced by game_lua_kernel::intf_allow_end_turn(), and lua_stringx::intf_str_format().
bool luaW_pcall | ( | lua_State * | L, |
int | nArgs, | ||
int | nRets, | ||
bool | allow_wml_error = false |
||
) |
Calls a Lua function stored below its nArgs arguments at the top of the stack.
L | the pointer to the lua interpreter. |
nArgs | |
nRets | LUA_MULTRET for unbounded return values. |
allow_wml_error | controls where any stack traces are output. |
Definition at line 1037 of file lua_common.cpp.
References chat_message(), e, ERR_LUA, lua_pop, lua_tostring, luaW_pcall_internal(), and lg::wml_error().
Referenced by game_lua_kernel::apply_effect(), ai::call_lua_filter_fcn(), lua_pathfind_cost_calculator::cost(), game_lua_kernel::custom_command(), lua_kernel_base::get_attribute_names(), ai::lua_ai_action_handler::handle(), intf_do_unsynced(), intf_invoke_synced_command(), game_lua_kernel::intf_scroll(), game_lua_kernel::intf_skip_messages(), game_lua_kernel::load_game(), luaW_getglobal(), game_lua_kernel::mouse_over_hex_callback(), game_lua_kernel::run_event(), game_lua_kernel::run_filter(), game_lua_kernel::run_wml_action(), game_lua_kernel::run_wml_conditional(), game_lua_kernel::save_game(), game_lua_kernel::select_hex_callback(), and ai::lua_ai_context::update_state().
int luaW_pcall_internal | ( | lua_State * | L, |
int | nArgs, | ||
int | nRets | ||
) |
Definition at line 1014 of file lua_common.cpp.
References executeKey, lua_getfield(), lua_gettop(), lua_insert, lua_pcall, LUA_REGISTRYINDEX, lua_remove, and lua_jailbreak_exception::rethrow().
Referenced by luaW_getglobal(), luaW_pcall(), and lua_kernel_base::protected_call().
Converts a config object to a Lua table pushed at the top of the stack.
Definition at line 733 of file lua_common.cpp.
References lua_newtable, and luaW_filltable().
Referenced by game_lua_kernel::apply_effect(), ai::cfun_ai_get_leader_goal(), game_lua_kernel::custom_command(), ai::lua_object< T >::from_type(), ai::lua_ai_action_handler::handle(), impl_context_accessor(), game_lua_kernel::impl_current_get(), impl_race_get(), game_lua_kernel::impl_theme_item(), impl_unit_type_get(), lua_common::impl_vconfig_get(), lua_wml::intf_clone_wml(), game_lua_kernel::intf_get_all_vars(), intf_get_era(), game_lua_kernel::intf_get_label(), intf_get_resource(), game_lua_kernel::intf_get_sound_source(), intf_get_traits(), intf_invoke_synced_command(), lua_wml::intf_load_wml(), lua_wml::intf_parse_wml(), intf_synchronize_choice(), lua_wml::intf_wml_diff(), lua_wml::intf_wml_interpolate(), lua_wml::intf_wml_merge(), lua_wml::intf_wml_patch(), game_lua_kernel::load_game(), lua_check_impl::lua_push(), mapgen_lua_kernel::run_generator(), lua_kernel_base::run_lua_tag(), application_lua_kernel::thread::run_script(), ai::lua_ai_context::set_arguments(), and ai::lua_ai_context::set_persistent_data().
void luaW_pushlocation | ( | lua_State * | L, |
const map_location & | loc | ||
) |
Converts a map location object to a Lua table pushed at the top of the stack.
Definition at line 665 of file lua_common.cpp.
References lua_createtable(), lua_pushinteger(), lua_rawseti(), map_location::wml_x(), and map_location::wml_y().
Referenced by ai::cfun_ai_get_targets(), ai::lua_object< T >::from_type(), impl_side_get(), impl_slocs_get(), impl_slocs_next(), impl_terrainmap_iter(), lua_map_location::intf_get_adjacent_tiles(), lua_map_location::intf_get_direction(), lua_map_location::intf_rotate_right_around_center(), game_lua_kernel::intf_select_hex(), intf_terrainmap_iter(), lua_map_location::intf_vector_diff(), lua_map_location::intf_vector_negation(), lua_map_location::intf_vector_sum(), lua_check_impl::lua_push(), luaW_pushfaivariant(), ai::push_attack_analysis(), ai::push_move_map(), and ai::push_movements().
void luaW_pushscalar | ( | lua_State * | L, |
const config::attribute_value & | v | ||
) |
Converts an attribute value into a Lua object pushed at the top of the stack.
Definition at line 566 of file lua_common.cpp.
References config_attribute_value::apply_visitor().
Referenced by impl_preferences_get(), lua_common::impl_vconfig_get(), lua_common::impl_vconfig_pairs_iter(), luaW_filltable(), and luaW_pushvariable().
Pushes a t_string on the top of the stack.
Definition at line 533 of file lua_common.cpp.
References b, d, i, lua_pushboolean(), lua_pushinteger(), lua_pushnil(), lua_pushnumber(), lua_pushstring(), luaL_setmetatable(), luaW_pushtstring(), s, and tstringKey.
Referenced by game_lua_kernel::impl_get_terrain_info(), lua_common::impl_gettext(), game_lua_kernel::intf_get_time_of_day(), lua_check_impl::lua_push(), and luaW_pushtstring().
bool luaW_pushvariable | ( | lua_State * | L, |
variable_access_const & | v | ||
) |
Definition at line 898 of file lua_common.cpp.
References variable_info< V >::as_container(), variable_info< V >::as_scalar(), variable_info< V >::exists_as_attribute(), variable_info< V >::exists_as_container(), variable_info< V >::get_error_message(), lua_newtable, lua_pushnil(), luaW_filltable(), luaW_pushscalar(), and WRN_LUA.
Referenced by impl_unit_variables_get(), mapgen_lua_kernel::intf_get_variable(), game_lua_kernel::intf_get_variable(), and luaW_getglobal().
Pushes a vconfig on the top of the stack.
Definition at line 527 of file lua_common.cpp.
References luaL_setmetatable(), and vconfigKey.
Referenced by lua_common::impl_vconfig_get(), lua_common::impl_vconfig_ipairs_iter(), lua_wml::intf_clone_wml(), lua_common::intf_tovconfig(), game_lua_kernel::run_wml_action(), and game_lua_kernel::run_wml_conditional().
bool luaW_tableget | ( | lua_State * | L, |
int | index, | ||
const char * | key | ||
) |
Definition at line 969 of file lua_common.cpp.
References lua_absindex(), lua_gettable(), lua_isnoneornil, lua_pop, and lua_pushstring().
Referenced by lua_stringx::intf_str_map_split(), lua_stringx::intf_str_split(), intf_terrain_mask(), luaW_getglobal(), read_rules_vector(), and filter_impl::~filter_impl().
bool luaW_toboolean | ( | lua_State * | L, |
int | n | ||
) |
Definition at line 893 of file lua_common.cpp.
References lua_toboolean().
Referenced by ai::ai_move(), ai::call_lua_filter_fcn(), game_lua_kernel::cfun_builtin_effect(), cfun_exec_candidate_action(), impl_add_animation(), ai::impl_ai_get(), impl_unit_status_set(), intf_add_modification(), intf_advance_unit(), game_lua_kernel::intf_allow_end_turn(), game_lua_kernel::intf_allow_undo(), game_lua_kernel::intf_delay(), game_lua_kernel::intf_find_cost_map(), intf_find_path(), game_lua_kernel::intf_get_time_of_day(), lua_fileops::intf_have_file(), lua_wml::intf_load_wml(), game_lua_kernel::intf_lock_view(), game_lua_kernel::intf_log(), intf_music_add(), intf_on_board(), game_lua_kernel::intf_put_unit(), game_lua_kernel::intf_redraw(), game_lua_kernel::intf_scroll_to_tile(), game_lua_kernel::intf_select_hex(), game_lua_kernel::intf_select_unit(), game_lua_kernel::intf_set_end_campaign_credits(), game_lua_kernel::intf_set_village_owner(), game_lua_kernel::intf_skip_messages(), lua_stringx::intf_str_paren_split(), game_lua_kernel::intf_teleport(), intf_terrainmap_iter(), game_lua_kernel::intf_toggle_fog(), intf_unit_resistance(), game_lua_kernel::intf_zoom(), ai::lua_ai_load::lua_ai_load(), lua_check_impl::lua_check(), lua_check_impl::lua_to_or_default(), luaW_checkvariable(), luaW_getglobal(), luaW_toscalar(), read_rules_vector(), game_lua_kernel::run_filter(), game_lua_kernel::run_wml_conditional(), lua_gui2::show_menu(), lua_gui2::show_message_box(), ai::lua_object< T >::to_type(), and WIDGET_SETTER().
Converts an optional table or vconfig to a config object.
L | the pointer to the lua interpreter. |
index | stack position of the table. |
cfg | the config to write the data to. |
Definition at line 745 of file lua_common.cpp.
References config::add_child(), i, lua_absindex(), lua_checkstack(), lua_gettop(), lua_istable, LUA_MINSTACK, lua_next(), lua_pop, lua_pushnil(), lua_rawgeti(), lua_rawlen(), lua_settop(), LUA_TNIL, LUA_TNONE, LUA_TNUMBER, lua_tostring, LUA_TSTRING, LUA_TTABLE, LUA_TUSERDATA, lua_type(), luaL_testudata(), luaW_toconfig(), luaW_toscalar(), return_misformed, config_attribute_value::str(), config::valid_attribute(), config::valid_tag(), and vconfigKey.
Referenced by mapgen_lua_kernel::create_scenario(), ai::lua_ai_context::get_arguments(), ai::lua_ai_context::get_persistent_data(), impl_context_accessor(), impl_music_set(), game_lua_kernel::intf_log_replay(), intf_modify_ai_old(), game_lua_kernel::intf_scroll(), game_lua_kernel::intf_skip_messages(), lua_wml::intf_wml_valid(), luaW_checkconfig(), luaW_checkvariable(), luaW_toconfig(), luaW_tovconfig(), game_lua_kernel::save_game(), lua_gui2::show_message_dialog(), and ai::lua_object< T >::to_type().
bool luaW_tolocation | ( | lua_State * | L, |
int | index, | ||
map_location & | loc | ||
) |
Converts an optional table or pair of integers to a map location object.
L | the pointer to the lua interpreter. |
index | stack position of the table or first integer. |
loc | the location to write to. |
Definition at line 676 of file lua_common.cpp.
References lua_absindex(), lua_checkstack(), lua_getfield(), lua_isnoneornil, lua_isnumber(), lua_istable, lua_isuserdata(), LUA_MINSTACK, lua_pop, lua_rawgeti(), lua_remove, lua_tonumber, lua_tonumberx(), luaW_tounit(), luaW_tovconfig(), map_location::set_wml_x(), map_location::set_wml_y(), and vconfig::unconstructed_vconfig().
Referenced by impl_add_animation(), impl_terrainmap_get(), impl_terrainmap_set(), lua_map_location::intf_distance_between(), game_lua_kernel::intf_erase_unit(), game_lua_kernel::intf_fire_event(), lua_map_location::intf_get_adjacent_tiles(), lua_map_location::intf_get_direction(), lua_map_location::intf_get_in_basis_N_NE(), lua_map_location::intf_get_relative_dir(), lua_map_location::intf_get_tiles_in_radius(), game_lua_kernel::intf_get_time_of_day(), game_lua_kernel::intf_get_unit(), game_lua_kernel::intf_get_units(), game_lua_kernel::intf_match_unit(), game_lua_kernel::intf_put_unit(), lua_map_location::intf_rotate_right_around_center(), lua_map_location::intf_tiles_adjacent(), intf_unit_defense(), intf_unit_jamming_cost(), intf_unit_movement_cost(), intf_unit_vision_cost(), lua_map_location::intf_vector_diff(), lua_map_location::intf_vector_negation(), lua_map_location::intf_vector_sum(), load_fake_units(), lua_check_impl::lua_to_or_default(), luaW_checklocation(), luaW_to_locationset(), and luaW_tofaivariant().
bool luaW_toscalar | ( | lua_State * | L, |
int | index, | ||
config::attribute_value & | v | ||
) |
Converts the value at the top of the stack to an attribute value.
Definition at line 571 of file lua_common.cpp.
References LUA_TBOOLEAN, LUA_TNUMBER, lua_tonumber, lua_tostring, LUA_TSTRING, LUA_TUSERDATA, lua_type(), luaL_testudata(), luaW_toboolean(), and tstringKey.
Referenced by impl_preferences_set(), and luaW_toconfig().
std::string_view luaW_tostring | ( | lua_State * | L, |
int | index | ||
) |
Definition at line 981 of file lua_common.cpp.
References lua_tolstring(), and luaL_error().
Referenced by lua_check_impl::lua_check(), luaW_getglobal(), read_rules_vector(), and filter_impl::~filter_impl().
std::string_view luaW_tostring_or_default | ( | lua_State * | L, |
int | index, | ||
std::string_view | def = std::string_view() |
||
) |
Definition at line 991 of file lua_common.cpp.
References lua_tolstring().
Referenced by lua_check_impl::lua_to_or_default(), and luaW_getglobal().
Converts a scalar to a translatable string.
Definition at line 598 of file lua_common.cpp.
References LUA_TBOOLEAN, LUA_TNUMBER, lua_toboolean(), lua_tostring, LUA_TSTRING, LUA_TUSERDATA, lua_type(), luaL_testudata(), and tstringKey.
Referenced by impl_add_animation(), game_lua_kernel::intf_allow_end_turn(), intf_synchronize_choice(), intf_synchronize_choices(), luaW_checktstring(), luaW_tofaivariant(), and lua_gui2::show_message_dialog().
Gets an optional vconfig from either a table or a userdata.
Definition at line 839 of file lua_common.cpp.
References LUA_TNIL, LUA_TNONE, LUA_TTABLE, LUA_TUSERDATA, lua_type(), luaL_testudata(), luaW_toconfig(), and vconfigKey.
Referenced by game_lua_kernel::intf_find_cost_map(), luaW_checkvconfig(), luaW_tofaivariant(), luaW_tolocation(), and ai::lua_object< T >::to_type().
int luaW_type_error | ( | lua_State * | L, |
int | narg, | ||
const char * | tname | ||
) |
Definition at line 1078 of file lua_common.cpp.
References lua_pushfstring(), luaL_argerror(), luaL_typename, and wfl::msg().
Referenced by ai::cfun_ai_get_suitable_keep(), impl_add_animation(), impl_unit_attacks_get(), impl_unit_attacks_len(), impl_unit_attacks_set(), impl_unit_status_get(), impl_unit_status_set(), impl_unit_variables_get(), impl_unit_variables_set(), lua_formula_bridge::intf_compile_formula(), intf_mg_get_locations(), intf_unit_defense(), intf_unit_jamming_cost(), intf_unit_movement_cost(), intf_unit_vision_cost(), luaW_check_mgfilter(), LuaW_checkcolor(), luaW_checkconfig(), luaW_checklocation(), luaW_checkterrainmap(), luaW_checktstring(), luaW_checkvariable(), luaW_checkvconfig(), luaW_getglobal(), lua_common::tstring_concat_aux(), unit_show_error(), and WIDGET_SETTER().
int luaW_type_error | ( | lua_State * | L, |
int | narg, | ||
const char * | kpath, | ||
const char * | tname | ||
) |
Definition at line 1086 of file lua_common.cpp.
References lua_pushfstring(), luaL_argerror(), luaL_typename, and wfl::msg().
void operator delete | ( | void * | p, |
lua_State * | L, | ||
int | nuv | ||
) |
Definition at line 504 of file lua_common.cpp.
References lua_pop.
void* operator new | ( | std::size_t | sz, |
lua_State * | L, | ||
int | nuv = 0 |
||
) |
Definition at line 499 of file lua_common.cpp.
References lua_newuserdatauv().
void push_error_handler | ( | lua_State * | L | ) |
Definition at line 1008 of file lua_common.cpp.
References executeKey, LUA_REGISTRYINDEX, lua_setfield(), and luaW_getglobal().
Referenced by lua_kernel_base::lua_kernel_base(), and luaW_getglobal().