mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Script:
- Added support for calling Lua functions with !PluginBang - Removed old (undocumented) implementation for handling mouse actions - Lua errors now contain the script file name only (instead of full path)
This commit is contained in:
@ -67,8 +67,21 @@ void LuaManager::CleanUp()
|
||||
|
||||
void LuaManager::ReportErrors(lua_State* L)
|
||||
{
|
||||
LuaLog(LOG_ERROR, "Script: %s", lua_tostring(L, -1));
|
||||
std::string error = lua_tostring(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Get rid of everything up to the filename
|
||||
std::string::size_type pos = 4; // Skip the drive
|
||||
pos = error.find_first_of(':', pos);
|
||||
pos = error.find_last_of('\\', pos);
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
error.erase(0, ++pos);
|
||||
}
|
||||
|
||||
std::wstring str = L"Script: ";
|
||||
str += ConvertToWide(error.c_str());
|
||||
Log(LOG_ERROR, str.c_str());
|
||||
}
|
||||
|
||||
void LuaManager::LuaLog(int nLevel, const char* format, ... )
|
||||
@ -89,15 +102,8 @@ void LuaManager::LuaLog(int nLevel, const char* format, ... )
|
||||
|
||||
_set_invalid_parameter_handler(oldHandler);
|
||||
|
||||
#ifndef _DEBUG
|
||||
// Forcing output to the Debug Output window!
|
||||
OutputDebugStringA(buffer);
|
||||
OutputDebugStringA("\n");
|
||||
#endif
|
||||
|
||||
std::wstring str = ConvertToWide(buffer);
|
||||
|
||||
LSLog(nLevel, L"Rainmeter", str.c_str());
|
||||
Log(nLevel, str.c_str());
|
||||
va_end(args);
|
||||
|
||||
delete [] buffer;
|
||||
|
@ -64,8 +64,7 @@ LuaScript::LuaScript(lua_State* state, const char* file) : m_State(state),
|
||||
if (result)
|
||||
{
|
||||
m_Initialized = false;
|
||||
LuaManager::LuaLog(LOG_ERROR, "Script: Could not run file: %s", lua_tostring(m_State, -1));
|
||||
lua_pop(m_State, 1);
|
||||
LuaManager::ReportErrors(m_State);
|
||||
|
||||
luaL_unref(m_State, LUA_GLOBALSINDEX, m_iRef);
|
||||
m_iRef = LUA_NOREF;
|
||||
@ -74,8 +73,7 @@ LuaScript::LuaScript(lua_State* state, const char* file) : m_State(state),
|
||||
else
|
||||
{
|
||||
m_Initialized = false;
|
||||
LuaManager::LuaLog(LOG_ERROR, "Script: Could not run file: %s", lua_tostring(m_State, -1));
|
||||
lua_pop(m_State, 1);
|
||||
LuaManager::ReportErrors(m_State);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,8 @@ static int Global_Log(lua_State* L)
|
||||
|
||||
static const luaL_reg TO_funcs[] =
|
||||
{
|
||||
{ "LuaLog", Global_Log }, { NULL, NULL }
|
||||
{ "LuaLog", Global_Log },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
void LuaManager::RegisterGlobal(lua_State* L)
|
||||
|
Reference in New Issue
Block a user