#include "lua_api.hpp"
#include "lua_types.hpp"
#include "lua_jailbreak_exception.hpp"
#include "chat_events.hpp"
#include "config.hpp"
#include "display_chat_manager.hpp"
#include "game_display.hpp"
#include "log.hpp"
#include "map/location.hpp"
#include "resources.hpp"
#include "scripting/lua_common.hpp"
#include "tstring.hpp"
#include "units/unit.hpp"
#include "units/map.hpp"
#include "variable.hpp"
#include <boost/variant/static_visitor.hpp>
#include <map>
#include <new>
#include <ostream>
#include <utility>
#include <string>
#include "lua/lauxlib.h"
#include "lua/lua.h"
Go to the source code of this file.
Macros | |
#define | LOG_LUA LOG_STREAM(info, log_scripting_lua) |
#define | ERR_LUA LOG_STREAM(err, log_scripting_lua) |
Functions | |
void | chat_message (std::string const &caption, std::string const &msg) |
Displays a message in the chat window. More... | |
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... | |
unit * | luaW_tounit (lua_State *L, int index, bool only_on_map) |
Converts a Lua value to a unit pointer. More... | |
unit_ptr | luaW_tounit_ptr (lua_State *L, int index, bool only_on_map) |
Similar to luaW_checkunit/luaW_tounit but returns a unit_ptr, use this instead of luaW_checkunit/luaW_tounit when uasing an api that needs unit_ptr. More... | |
unit_ptr | luaW_checkunit_ptr (lua_State *L, int index, bool only_on_map) |
unit & | luaW_checkunit (lua_State *L, int index, bool only_on_map) |
Converts a Lua value to a unit pointer. More... | |
lua_unit * | luaW_pushlocalunit (lua_State *L, unit &u) |
Variables | |
static lg::log_domain | log_scripting_lua ("scripting/lua") |
#define ERR_LUA LOG_STREAM(err, log_scripting_lua) |
Definition at line 46 of file lua_api.cpp.
Referenced by luaW_pcall(), and lua_unit::put_map().
#define LOG_LUA LOG_STREAM(info, log_scripting_lua) |
Definition at line 45 of file lua_api.cpp.
void chat_message | ( | std::string const & | caption, |
std::string const & | msg | ||
) |
Displays a message in the chat window.
Definition at line 48 of file lua_api.cpp.
References display_chat_manager::add_chat_message(), game_display::get_chat_manager(), events::chat_handler::MESSAGE_PUBLIC, and resources::screen.
Referenced by display_chat_manager::add_chat_message(), chat_log::add_message(), and luaW_pcall().
Converts a Lua value to a unit pointer.
Definition at line 205 of file lua_api.cpp.
References luaL_typerror(), and luaW_tounit().
Referenced by game_lua_kernel::cfun_builtin_effect(), impl_unit_equality(), intf_add_modification(), intf_advance_unit(), intf_copy_unit(), game_lua_kernel::intf_find_path(), game_lua_kernel::intf_find_reach(), game_lua_kernel::intf_simulate_combat(), intf_transform_unit(), intf_unit_ability(), intf_unit_defense(), intf_unit_jamming_cost(), intf_unit_movement_cost(), intf_unit_resistance(), and intf_unit_vision_cost().
Definition at line 199 of file lua_api.cpp.
References luaL_typerror(), and luaW_tounit().
Referenced by game_lua_kernel::intf_teleport().
Calls a Lua function stored below its nArgs arguments at the top of the stack.
nRets | LUA_MULTRET for unbounded return values. |
Definition at line 59 of file lua_api.cpp.
References chat_message(), e, ERR_LUA, executeKey, lua_gettop(), lua_insert(), lua_pcall, lua_pop, lua_pushlightuserdata(), lua_rawget(), LUA_REGISTRYINDEX, lua_remove(), lua_tostring, tlua_jailbreak_exception::rethrow(), and lg::wml_error().
Referenced by game_lua_kernel::apply_effect(), ai::call_lua_filter_fcn(), lua_pathfind_cost_calculator::cost(), ai::lua_ai_action_handler::handle(), intf_do_unsynced(), game_lua_kernel::load_game(), 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().
Definition at line 212 of file lua_api.cpp.
References getunitKey, lua_newuserdata(), lua_pushlightuserdata(), lua_rawget(), LUA_REGISTRYINDEX, and lua_setmetatable().
Referenced by game_lua_kernel::apply_effect().
Converts a Lua value to a unit pointer.
Definition at line 183 of file lua_api.cpp.
References lua_unit::get(), getunitKey, lua_touserdata(), luaW_hasmetatable(), and lua_unit::on_map().
Referenced by ai::cfun_ai_get_suitable_keep(), impl_unit_attack_get(), impl_unit_attack_set(), impl_unit_attacks_get(), impl_unit_attacks_len(), impl_unit_status_get(), impl_unit_status_set(), impl_unit_variables_get(), impl_unit_variables_set(), lua_formula_bridge::intf_eval_formula(), game_lua_kernel::intf_find_cost_map(), luaW_checkunit(), luaW_checkunit_ptr(), luaW_tofaivariant(), and luaW_tolocation().
Similar to luaW_checkunit/luaW_tounit but returns a unit_ptr, use this instead of luaW_checkunit/luaW_tounit when uasing an api that needs unit_ptr.
Definition at line 191 of file lua_api.cpp.
References lua_unit::get_shared(), getunitKey, lua_touserdata(), luaW_hasmetatable(), and lua_unit::on_map().
|
static |