diff --git a/GlobalMethods.h b/GlobalMethods.h index cd7b731..c179582 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -2279,5 +2279,46 @@ namespace LuaGlobalFunctions Eluna::Push(E->L, ElunaUtil::GetTimeDiff(oldtimems)); return 1; } + + std::string GetStackAsString(Eluna* E) + { + std::ostringstream oss; + for (int i = 1; i <= lua_gettop(E->L); ++i) + oss << luaL_tolstring(E->L, i, NULL); + return oss.str(); + } + + /** + * Prints given parameters to the info log + * + * @param ... variableArguments + */ + int PrintInfo(Eluna* E) + { + ELUNA_LOG_INFO("%s", GetStackAsString(E).c_str()); + return 0; + } + + /** + * Prints given parameters to the error log + * + * @param ... variableArguments + */ + int PrintError(Eluna* E) + { + ELUNA_LOG_ERROR("%s", GetStackAsString(E).c_str()); + return 0; + } + + /** + * Prints given parameters to the debug log + * + * @param ... variableArguments + */ + int PrintDebug(Eluna* E) + { + ELUNA_LOG_DEBUG("%s", GetStackAsString(E).c_str()); + return 0; + } } #endif diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index a0a84cd..29cc80a 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -87,6 +87,9 @@ ElunaGlobal::ElunaRegister GlobalMethods[] = { "GetMapById", &LuaGlobalFunctions::GetMapById }, { "GetCurrTime", &LuaGlobalFunctions::GetCurrTime }, { "GetTimeDiff", &LuaGlobalFunctions::GetTimeDiff }, + { "PrintInfo", &LuaGlobalFunctions::PrintInfo }, + { "PrintError", &LuaGlobalFunctions::PrintError }, + { "PrintDebug", &LuaGlobalFunctions::PrintDebug }, // Boolean { "IsInventoryPos", &LuaGlobalFunctions::IsInventoryPos },