aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api
ModeNameSize
-rw-r--r--CMakeLists.txt604logplain
-rw-r--r--s_async.cpp7943logplain
-rw-r--r--s_async.h4270logplain
-rw-r--r--s_base.cpp6748logplain
-rw-r--r--s_base.h2552logplain
-rw-r--r--s_entity.cpp7600logplain
-rw-r--r--s_entity.h1542logplain
-rw-r--r--s_env.cpp5125logplain
-rw-r--r--s_env.h1405logplain
-rw-r--r--s_internal.h2282logplain
-rw-r--r--s_inventory.cpp7346logplain
-rw-r--r--s_inventory.h2342logplain
-rw-r--r--s_item.cpp6566logplain
-rw-r--r--s_item.h1879logplain
-rw-r--r--s_mainmenu.cpp2410logplain
-rw-r--r--s_mainmenu.h1442logplain
-rw-r--r--s_node.cpp6469logplain
-rw-r--r--s_node.h1971logplain
-rw-r--r--s_nodemeta.cpp7783logplain
-rw-r--r--s_nodemeta.h2220logplain
-rw-r--r--s_player.cpp4341logplain
-rw-r--r--s_player.h1542logplain
-rw-r--r--s_server.cpp4329logplain
-rw-r--r--s_server.h1559logplain
class="hl kwa">if (!fxn) fxn = "??"; const char *err_descr = lua_tostring(L, -1); if (!err_descr) err_descr = "<no description>"; char buf[256]; snprintf(buf, sizeof(buf), "%s error from mod '%s' in callback %s(): ", err_type, mod, fxn); std::string err_msg(buf); err_msg += err_descr; if (pcall_result == LUA_ERRMEM) { err_msg += "\nCurrent Lua memory usage: " + itos(lua_gc(L, LUA_GCCOUNT, 0) >> 10) + " MB"; } throw LuaError(err_msg); } // Push the list of callbacks (a lua table). // Then push nargs arguments. // Then call this function, which // - runs the callbacks // - replaces the table and arguments with the return value, // computed depending on mode void script_run_callbacks_f(lua_State *L, int nargs, RunCallbacksMode mode, const char *fxn) { FATAL_ERROR_IF(lua_gettop(L) < nargs + 1, "Not enough arguments"); // Insert error handler PUSH_ERROR_HANDLER(L); int error_handler = lua_gettop(L) - nargs - 1; lua_insert(L, error_handler); // Insert run_callbacks between error handler and table lua_getglobal(L, "core"); lua_getfield(L, -1, "run_callbacks"); lua_remove(L, -2); lua_insert(L, error_handler + 1); // Insert mode after table lua_pushnumber(L, (int) mode); lua_insert(L, error_handler + 3); // Stack now looks like this: // ... <error handler> <run_callbacks> <table> <mode> <arg#1> <arg#2> ... <arg#n> int result = lua_pcall(L, nargs + 2, 1, error_handler); if (result != 0) script_error(L, result, NULL, fxn); lua_remove(L, error_handler); } void log_deprecated(lua_State *L, const std::string &message) { static bool configured = false; static bool do_log = false; static bool do_error = false; // Only read settings on first call if (!configured) { std::string value = g_settings->get("deprecated_lua_api_handling"); if (value == "log") { do_log = true;