Contains code common to the application and game lua kernels which cannot or should not go into the lua kernel base files. More...
#include "scripting/lua_common.hpp"#include "config.hpp"#include "scripting/push_check.hpp"#include "tstring.hpp"#include "variable.hpp"#include "log.hpp"#include "gettext.hpp"#include "lua_jailbreak_exception.hpp"#include "game_display.hpp"#include <cstring>#include <iterator>#include <string>Go to the source code of this file.
Namespaces | |
| lua_common | |
Macros | |
| #define | LOG_LUA LOG_STREAM(info, log_scripting_lua) |
| #define | WRN_LUA LOG_STREAM(warn, log_scripting_lua) |
| #define | ERR_LUA LOG_STREAM(err, log_scripting_lua) |
| #define | ERR_WML LOG_STREAM(err, log_wml) |
| #define | return_misformed() do { lua_settop(L, initial_top); return false; } while (0) |
Functions | |
| static int | lua_common::impl_gettext (lua_State *L) |
| Creates a t_string object (__call metamethod). More... | |
| static int | lua_common::impl_gettext_tostr (lua_State *L) |
| int | lua_common::intf_textdomain (lua_State *L) |
| Creates an interface for gettext. More... | |
| static void | lua_common::tstring_concat_aux (lua_State *L, t_string &dst, int src) |
| Converts a Lua value at position src and appends it to dst. More... | |
| static int | lua_common::impl_tstring_concat (lua_State *L) |
| Appends a scalar to a t_string object (__concat metamethod). More... | |
| static int | lua_common::impl_tstring_len (lua_State *L) |
| static int | lua_common::impl_tstring_collect (lua_State *L) |
| Destroys a t_string object before it is collected (__gc metamethod). More... | |
| static int | lua_common::impl_tstring_lt (lua_State *L) |
| static int | lua_common::impl_tstring_le (lua_State *L) |
| static int | lua_common::impl_tstring_eq (lua_State *L) |
| static int | lua_common::impl_tstring_tostring (lua_State *L) |
| Converts a t_string object to a string (__tostring metamethod); that is, performs a translation. More... | |
| static int | lua_common::impl_vconfig_get (lua_State *L) |
| Gets the parsed field of a vconfig object (_index metamethod). More... | |
| static int | lua_common::impl_vconfig_dir (lua_State *L) |
| static int | lua_common::impl_vconfig_size (lua_State *L) |
| Returns the number of a child of a vconfig object. More... | |
| static int | lua_common::impl_vconfig_collect (lua_State *L) |
| Destroys a vconfig object before it is collected (__gc metamethod). More... | |
| static int | lua_common::impl_vconfig_pairs_iter (lua_State *L) |
| Iterate through the attributes of a vconfig. More... | |
| static int | lua_common::impl_vconfig_pairs_collect (lua_State *L) |
| Destroy a vconfig pairs iterator. More... | |
| static int | lua_common::impl_vconfig_pairs (lua_State *L) |
| Construct an iterator to iterate through the attributes of a vconfig. 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) |
| void | operator delete (void *, lua_State *L, int) |
| 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... | |
| static int | impl_namedtuple_get (lua_State *L) |
| static int | impl_namedtuple_set (lua_State *L) |
| static int | impl_namedtuple_dir (lua_State *L) |
| static int | impl_namedtuple_tostring (lua_State *L) |
| static int | impl_namedtuple_compare (lua_State *L) |
| void | luaW_push_namedtuple (lua_State *L, const std::vector< std::string > &names) |
| Push an empty "named tuple" onto the stack. More... | |
| std::vector< std::string > | luaW_to_namedtuple (lua_State *L, int idx) |
| Get the keys of a "named tuple" from the stack. More... | |
| void | luaW_pushlocation (lua_State *L, const map_location &ml) |
| 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... | |
| int | luaW_push_locationset (lua_State *L, const std::set< map_location > &locs) |
| Converts a set of map locations to a Lua table pushed at the top of the stack. More... | |
| std::set< map_location > | luaW_check_locationset (lua_State *L, int idx) |
| Converts a table of integer pairs to a set of map location objects. 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... | |
| luaW_PrintStack | luaW_debugstack (lua_State *L) |
| std::ostream & | operator<< (std::ostream &os, const luaW_PrintStack &s) |
| 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... | |
| 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_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) |
| Gets an optional vconfig from either a table or a userdata. 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... | |
| 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) |
| void | chat_message (const std::string &caption, const std::string &msg) |
| Displays a message in the chat window. More... | |
| void | push_error_handler (lua_State *L) |
| int | luaW_pcall_internal (lua_State *L, int nArgs, int nRets) |
| bool | luaW_pcall (lua_State *L, int nArgs, int nRets, bool allow_wml_error) |
| Calls a Lua function stored below its nArgs arguments at the top of the stack. More... | |
| 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) |
Variables | |
| static const char | gettextKey [] = "gettext" |
| static const char | vconfigKey [] = "vconfig" |
| static const char | vconfigpairsKey [] = "vconfig pairs" |
| static const char | tstringKey [] = "translatable string" |
| static const char | executeKey [] = "err" |
| static lg::log_domain | log_scripting_lua ("scripting/lua") |
| static lg::log_domain | log_wml ("wml") |
Contains code common to the application and game lua kernels which cannot or should not go into the lua kernel base files.
Currently contains implementation functions related to vconfig and gettext, also some macros to assist in writing C lua callbacks.
Definition in file lua_common.cpp.
| #define ERR_LUA LOG_STREAM(err, log_scripting_lua) |
Definition at line 50 of file lua_common.cpp.
| #define ERR_WML LOG_STREAM(err, log_wml) |
Definition at line 53 of file lua_common.cpp.
| #define LOG_LUA LOG_STREAM(info, log_scripting_lua) |
Definition at line 48 of file lua_common.cpp.
| #define return_misformed | ( | ) | do { lua_settop(L, initial_top); return false; } while (0) |
Definition at line 890 of file lua_common.cpp.
| #define WRN_LUA LOG_STREAM(warn, log_scripting_lua) |
Definition at line 49 of file lua_common.cpp.
| void chat_message | ( | const std::string & | caption, |
| const std::string & | msg | ||
| ) |
Displays a message in the chat window.
Definition at line 1149 of file lua_common.cpp.
References display_chat_manager::add_chat_message(), game_display::get_chat_manager(), game_display::get_singleton(), events::chat_handler::MESSAGE_PUBLIC, and wfl::msg().
Referenced by luaW_pcall().
|
static |
|
static |
Definition at line 673 of file lua_common.cpp.
Referenced by luaW_push_namedtuple().
|
static |
Definition at line 637 of file lua_common.cpp.
References utils::find(), i, and names.
Referenced by luaW_push_namedtuple().
|
static |
Definition at line 653 of file lua_common.cpp.
References utils::find(), i, and names.
Referenced by luaW_push_namedtuple().
|
static |
Definition at line 679 of file lua_common.cpp.
References i, utils::join(), and lua_push().
Referenced by luaW_push_namedtuple().
| std::set<map_location> luaW_check_locationset | ( | lua_State * | L, |
| int | idx | ||
| ) |
Converts a table of integer pairs to a set of map location objects.
Definition at line 848 of file lua_common.cpp.
References i, luaW_checklocation(), and luaW_type_error().
Referenced by game_lua_kernel::intf_add_time_area(), intf_make_shroud_bitmap(), game_lua_kernel::intf_override_shroud(), game_lua_kernel::intf_toggle_fog(), and game_lua_kernel::intf_toggle_shroud().
| config luaW_checkconfig | ( | lua_State * | L, |
| int | index | ||
| ) |
Converts an optional table or vconfig to a config object.
Definition at line 971 of file lua_common.cpp.
References utf8::index(), luaW_toconfig(), and luaW_type_error().
Referenced by game_lua_kernel::cfun_builtin_effect(), impl_context_backend(), game_lua_kernel::impl_schedule_set(), impl_unit_attack_match(), impl_unit_attack_set(), impl_unit_attacks_set(), intf_add_modification(), game_lua_kernel::intf_add_time_area(), 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(), 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_show_dialog(), lua_gui2::intf_show_recall_dialog(), lua_gui2::intf_show_recruit_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 979 of file lua_common.cpp.
References utf8::index(), 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 828 of file lua_common.cpp.
References utf8::index(), luaW_tolocation(), and luaW_type_error().
Referenced by ai::ai_attack(), ai::ai_move(), ai::ai_stopunit_select(), impl_slocs_set(), impl_source_set(), impl_terrainmap_iter(), game_lua_kernel::intf_add_tile_overlay(), game_lua_kernel::intf_find_cost_map(), game_lua_kernel::intf_find_path(), intf_find_path(), game_lua_kernel::intf_find_reach(), game_lua_kernel::intf_find_vacant_tile(), game_lua_kernel::intf_find_vision_range(), 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_label(), game_lua_kernel::intf_remove_tile_overlay(), game_lua_kernel::intf_scroll_to_tile(), game_lua_kernel::intf_select_unit(), game_lua_kernel::intf_set_floating_label(), game_lua_kernel::intf_set_village_owner(), game_lua_kernel::intf_teleport(), intf_terrain_mask(), intf_unit_resistance(), lua_check_impl::lua_check(), luaW_check_locationset(), and luaW_to_locationset().
| t_string luaW_checktstring | ( | lua_State * | L, |
| int | index | ||
| ) |
Converts a scalar to a translatable string.
Definition at line 595 of file lua_common.cpp.
References utf8::index(), 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_floating_label(), 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 1075 of file lua_common.cpp.
References variable_info< V >::as_container(), variable_info< V >::as_scalar(), cfg, variable_info< V >::get_error_message(), luaW_toboolean(), luaW_toconfig(), luaW_tostring(), luaW_type_error(), n, tstringKey, and WRN_LUA.
Referenced by impl_unit_variables_set(), and game_lua_kernel::intf_set_variable().
| vconfig luaW_checkvconfig | ( | lua_State * | L, |
| int | index, | ||
| bool | allow_missing = false |
||
| ) |
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 1015 of file lua_common.cpp.
References utf8::index(), 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_pairs(), lua_common::impl_vconfig_pairs_iter(), game_lua_kernel::intf_add_event_wml(), game_lua_kernel::intf_add_label(), game_lua_kernel::intf_add_tile_overlay(), game_lua_kernel::intf_add_time_area(), intf_eval_conditional(), 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_match_location(), game_lua_kernel::intf_match_side(), game_lua_kernel::intf_match_unit(), game_lua_kernel::intf_redraw(), game_lua_kernel::intf_replace_schedule(), game_lua_kernel::intf_set_menu_item(), lua_common::intf_tovconfig(), and lua_check_impl::lua_check().
| luaW_PrintStack luaW_debugstack | ( | lua_State * | L | ) |
Definition at line 870 of file lua_common.cpp.
| void luaW_filltable | ( | lua_State * | L, |
| const config & | cfg | ||
| ) |
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 614 of file lua_common.cpp.
References config::all_children_view(), config::attribute_range(), cfg, luaW_push_namedtuple(), and luaW_pushscalar().
Referenced by 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 1023 of file lua_common.cpp.
References game_config::path, and s.
Referenced by application_lua_kernel::application_lua_kernel(), game_lua_kernel::apply_effect(), ai::lua_ai_context::apply_micro_ai(), game_lua_kernel::custom_command(), luaW_Registry::dir(), game_lua_kernel::game_lua_kernel(), luaW_Registry::get(), impl_get_callback(), impl_mp_settings_get(), lua_stringx::impl_str_index(), impl_terrainmap_get(), impl_warn(), lua_widget::impl_widget_dir(), lua_widget::impl_widget_get(), lua_kernel_base::interactive_run(), intf_invoke_synced_command(), intf_object_dir(), intf_run_event_wml(), game_lua_kernel::intf_set_achievement(), lua_kernel_base::load_core(), lua_kernel_base::lua_kernel_base(), luaW_getglobal(), luaW_serialize_function(), mapgen_lua_kernel::mapgen_lua_kernel(), operator<<(), push_error_handler(), lua_audio::register_table(), lua_common::register_tstring_metatable(), game_lua_kernel::run_filter(), game_lua_kernel::run_wml_action(), game_lua_kernel::run_wml_conditional(), and WIDGET_SETTER().
| 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 484 of file lua_common.cpp.
References n.
Referenced by impl_animator_get(), impl_floating_label_getmethod(), impl_music_get(), impl_source_get(), impl_track_get(), and impl_unit_attack_get().
| bool luaW_iststring | ( | lua_State * | L, |
| int | index | ||
| ) |
Definition at line 603 of file lua_common.cpp.
References utf8::index(), 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 1188 of file lua_common.cpp.
References chat_message(), e, ERR_LUA, ERR_WML, lg::log_to_chat(), and luaW_pcall_internal().
Referenced by game_lua_kernel::apply_effect(), ai::lua_ai_context::apply_micro_ai(), ai::call_lua_filter_fcn(), game_lua_kernel::cfun_undoable_event(), 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_set_achievement(), game_lua_kernel::load_game(), game_lua_kernel::mouse_button_callback(), 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::run_wml_event(), 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 1162 of file lua_common.cpp.
References executeKey, lua_jailbreak_exception::jail_depth, and lua_jailbreak_exception::rethrow().
Referenced by luaW_pcall(), and lua_kernel_base::protected_call().
| int luaW_push_locationset | ( | lua_State * | L, |
| const std::set< map_location > & | locs | ||
| ) |
Converts a set of map locations to a Lua table pushed at the top of the stack.
Definition at line 836 of file lua_common.cpp.
References i, loc, and luaW_pushlocation().
Referenced by ai::cfun_ai_get_avoid(), game_lua_kernel::intf_get_locations(), intf_mg_get_locations(), intf_mg_get_tiles_radius(), and intf_parse_shroud_bitmap().
| void luaW_push_namedtuple | ( | lua_State * | L, |
| const std::vector< std::string > & | names | ||
| ) |
Push an empty "named tuple" onto the stack.
A named tuple is an array where each index can also be accessed by name. Once it's pushed, you can set the elements, eg with lua_rawseti.
Definition at line 723 of file lua_common.cpp.
References i, impl_namedtuple_compare(), impl_namedtuple_dir(), impl_namedtuple_get(), impl_namedtuple_set(), impl_namedtuple_tostring(), lua_push(), and names.
Referenced by lua_common::impl_vconfig_get(), game_lua_kernel::intf_find_cost_map(), game_lua_kernel::intf_find_reach(), game_lua_kernel::intf_find_vision_range(), intf_named_tuple(), luaW_copy_upvalues(), luaW_filltable(), luaW_pushcubeloc(), luaW_pushlocation(), and push_color_palette().
| void luaW_pushconfig | ( | lua_State * | L, |
| const config & | cfg | ||
| ) |
Converts a config object to a Lua table pushed at the top of the stack.
Definition at line 864 of file lua_common.cpp.
References cfg, and luaW_filltable().
Referenced by game_lua_kernel::apply_effect(), ai::lua_ai_context::apply_micro_ai(), 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(), impl_mp_settings_get(), impl_race_get(), game_lua_kernel::impl_theme_item(), lua_common::impl_vconfig_get(), lua_wml::intf_clone_wml(), intf_execute(), game_lua_kernel::intf_get_achievement(), game_lua_kernel::intf_get_all_vars(), mapgen_lua_kernel::intf_get_all_vars(), intf_get_era(), game_lua_kernel::intf_get_label(), intf_get_resource(), 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(), lua_kernel_base::load_binary(), game_lua_kernel::load_game(), lua_check_impl::lua_push(), luaW_copy_upvalues(), 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 & | ml | ||
| ) |
Converts a map location object to a Lua table pushed at the top of the stack.
Definition at line 768 of file lua_common.cpp.
References luaW_push_namedtuple(), map_location::wml_x(), and map_location::wml_y().
Referenced by ai::cfun_ai_get_targets(), ai::lua_object< T >::from_type(), impl_slocs_get(), impl_slocs_next(), impl_source_get(), impl_terrainmap_iter(), game_lua_kernel::intf_find_path(), lua_map_location::intf_get_adjacent_tiles(), lua_map_location::intf_get_direction(), lua_map_location::intf_get_from_cubic(), lua_map_location::intf_rotate_right_around_center(), 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_push_locationset(), 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 538 of file lua_common.cpp.
References config_attribute_value::apply_visitor().
Referenced by lua_common::impl_vconfig_get(), lua_common::impl_vconfig_pairs_iter(), lua_kernel_base::load_binary(), luaW_copy_upvalues(), luaW_filltable(), and luaW_pushvariable().
| void luaW_pushtstring | ( | lua_State * | L, |
| const t_string & | v | ||
| ) |
Pushes a t_string on the top of the stack.
Definition at line 505 of file lua_common.cpp.
References tstringKey.
Referenced by game_lua_kernel::impl_get_terrain_info(), lua_common::impl_gettext(), game_lua_kernel::intf_set_achievement(), lua_check_impl::lua_push(), and luaW_push_tod().
| bool luaW_pushvariable | ( | lua_State * | L, |
| variable_access_const & | v | ||
| ) |
Definition at line 1047 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(), luaW_filltable(), luaW_pushscalar(), and WRN_LUA.
Referenced by impl_unit_variables_get(), game_lua_kernel::intf_get_variable(), and mapgen_lua_kernel::intf_get_variable().
| void luaW_pushvconfig | ( | lua_State * | L, |
| const vconfig & | cfg | ||
| ) |
Pushes a vconfig on the top of the stack.
Definition at line 499 of file lua_common.cpp.
References cfg, and vconfigKey.
Referenced by lua_common::impl_vconfig_get(), lua_wml::intf_clone_wml(), lua_common::intf_tovconfig(), lua_check_impl::lua_push(), game_lua_kernel::run_wml_action(), game_lua_kernel::run_wml_conditional(), and game_lua_kernel::run_wml_event().
| bool luaW_tableget | ( | lua_State * | L, |
| int | index, | ||
| const char * | key | ||
| ) |
Definition at line 1117 of file lua_common.cpp.
References utf8::index().
Referenced by impl_widget_length(), game_lua_kernel::intf_add_event(), intf_execute(), intf_find_path(), game_lua_kernel::intf_set_floating_label(), lua_stringx::intf_str_map_split(), lua_stringx::intf_str_split(), intf_terrain_mask(), luaW_tocubeloc(), and read_rules_vector().
| std::vector<std::string> luaW_to_namedtuple | ( | lua_State * | L, |
| int | idx | ||
| ) |
Get the keys of a "named tuple" from the stack.
Returns an empty array if the stack element is not a named tuple.
Definition at line 755 of file lua_common.cpp.
References names.
Referenced by luaW_serialize_function().
| bool luaW_toboolean | ( | lua_State * | L, |
| int | n | ||
| ) |
Definition at line 1042 of file lua_common.cpp.
References n.
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_get_dir_suffix(), impl_is_deprecated(), 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(), 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_unit(), 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_get_attributes(), luaW_toscalar(), game_lua_kernel::mouse_button_callback(), read_rules_vector(), game_lua_kernel::run_filter(), game_lua_kernel::run_wml_conditional(), game_lua_kernel::run_wml_event(), lua_gui2::show_menu(), lua_gui2::show_message_box(), ai::lua_object< T >::to_type(), and WIDGET_SETTER().
| bool luaW_toconfig | ( | lua_State * | L, |
| int | index, | ||
| config & | cfg | ||
| ) |
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 893 of file lua_common.cpp.
References config::add_child(), cfg, config::clear(), i, utf8::index(), 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(), impl_sndsrc_set(), game_lua_kernel::intf_add_event(), game_lua_kernel::intf_add_undo_actions(), game_lua_kernel::intf_fire_event(), game_lua_kernel::intf_log_replay(), intf_modify_ai_old(), lua_wml::intf_wml_valid(), lua_check_impl::lua_to_or_default(), luaW_checkconfig(), luaW_checkvariable(), luaW_serialize_function(), luaW_tovconfig(), lua_kernel_base::run_binary_lua_tag(), 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 779 of file lua_common.cpp.
References utf8::index(), loc, map_location::set_wml_x(), map_location::set_wml_y(), and vconfig::unconstructed_vconfig().
Referenced by ai::ai_recall(), ai::ai_recruit(), impl_add_animation(), impl_source_set(), 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_cubic(), lua_map_location::intf_get_relative_dir(), lua_map_location::intf_get_tile_ring(), lua_map_location::intf_get_tiles_in_radius(), game_lua_kernel::intf_get_time_area(), 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 543 of file lua_common.cpp.
References utf8::index(), luaW_toboolean(), luaW_tostring(), and tstringKey.
Referenced by luaW_serialize_function(), luaW_toconfig(), and lua_kernel_base::run_binary_lua_tag().
| std::string_view luaW_tostring | ( | lua_State * | L, |
| int | index | ||
| ) |
Definition at line 1129 of file lua_common.cpp.
References utf8::index().
Referenced by game_lua_kernel::intf_set_floating_label(), lua_check_impl::lua_check(), luaW_checkvariable(), luaW_toscalar(), and read_rules_vector().
| std::string_view luaW_tostring_or_default | ( | lua_State * | L, |
| int | index, | ||
| std::string_view | def | ||
| ) |
Definition at line 1139 of file lua_common.cpp.
References utf8::index().
Referenced by lua_check_impl::lua_to_or_default().
| bool luaW_totstring | ( | lua_State * | L, |
| int | index, | ||
| t_string & | str | ||
| ) |
Converts a scalar to a translatable string.
Definition at line 570 of file lua_common.cpp.
References utf8::index(), 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().
| bool luaW_tovconfig | ( | lua_State * | L, |
| int | index, | ||
| vconfig & | vcfg | ||
| ) |
Gets an optional vconfig from either a table or a userdata.
Definition at line 988 of file lua_common.cpp.
References cfg, utf8::index(), luaW_toconfig(), and vconfigKey.
Referenced by game_lua_kernel::intf_add_time_area(), game_lua_kernel::intf_find_cost_map(), game_lua_kernel::intf_gamestate_inspector(), lua_check_impl::lua_to_or_default(), luaW_checkvconfig(), luaW_tofaivariant(), and ai::lua_object< T >::to_type().
| int luaW_type_error | ( | lua_State * | L, |
| int | narg, | ||
| const char * | kpath, | ||
| const char * | tname | ||
| ) |
Definition at line 1242 of file lua_common.cpp.
References wfl::msg().
| int luaW_type_error | ( | lua_State * | L, |
| int | narg, | ||
| const char * | tname | ||
| ) |
Definition at line 1234 of file lua_common.cpp.
References 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_dir(), impl_unit_status_get(), impl_unit_status_set(), impl_unit_variables_dir(), impl_unit_variables_get(), impl_unit_variables_set(), lua_formula_bridge::intf_compile_formula(), intf_named_tuple(), game_lua_kernel::intf_override_shroud(), game_lua_kernel::intf_screen_fade(), intf_unit_defense(), intf_unit_jamming_cost(), intf_unit_movement_cost(), intf_unit_vision_cost(), luaW_check_formula(), luaW_check_locationset(), luaW_check_mgfilter(), LuaW_checkcolor(), luaW_checkconfig(), luaW_checklocation(), luaW_checkterrainmap(), luaW_checktstring(), luaW_checkvariable(), luaW_checkvconfig(), lua_common::tstring_concat_aux(), unit_show_error(), and WIDGET_SETTER().
| void operator delete | ( | void * | p, |
| lua_State * | L, | ||
| int | nuv | ||
| ) |
Definition at line 476 of file lua_common.cpp.
| void* operator new | ( | std::size_t | sz, |
| lua_State * | L, | ||
| int | nuv | ||
| ) |
Definition at line 471 of file lua_common.cpp.
| std::ostream& operator<< | ( | std::ostream & | os, |
| const luaW_PrintStack & | s | ||
| ) |
Definition at line 874 of file lua_common.cpp.
References flush(), i, luaW_getglobal(), and s.
| void push_error_handler | ( | lua_State * | L | ) |
Definition at line 1156 of file lua_common.cpp.
References executeKey, and luaW_getglobal().
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Definition at line 45 of file lua_common.cpp.
Referenced by luaW_pcall_internal(), and push_error_handler().
|
static |
Definition at line 41 of file lua_common.cpp.
Referenced by lua_common::intf_textdomain(), and lua_common::register_gettext_metatable().
|
static |
|
static |
|
static |
Definition at line 44 of file lua_common.cpp.
Referenced by lua_common::impl_tstring_concat(), lua_common::impl_tstring_le(), lua_common::impl_tstring_lt(), luaW_checkvariable(), luaW_iststring(), luaW_pushtstring(), luaW_toscalar(), luaW_totstring(), lua_common::register_tstring_metatable(), and lua_common::tstring_concat_aux().
|
static |
Definition at line 42 of file lua_common.cpp.
Referenced by luaW_checkconfig(), luaW_pushvconfig(), luaW_toconfig(), luaW_tovconfig(), and lua_common::register_vconfig_metatable().
|
static |
Definition at line 43 of file lua_common.cpp.
Referenced by lua_common::impl_vconfig_pairs(), lua_common::impl_vconfig_pairs_iter(), and lua_common::register_vconfig_metatable().