Skip to content

Commit

Permalink
Log Lua exceptions to game log
Browse files Browse the repository at this point in the history
  • Loading branch information
EddieEldridge committed Dec 28, 2024
1 parent 695d436 commit 402550b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion M2TWEOP Code/M2TWEOP library/luaEop3dObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void luaPlugin::initEop3dObjects()
3d text object. Not use it onPluginLoad(graphics system not initialized here yet).
@tfield float xSize default value 1
@tfield float ySize default value 0.2
@tfield float zSize default value 1
@tfield float zSize default value 1
@tfield float xRoll default value 1
@tfield float yRoll default value 90
@tfield float zRoll default value 1
Expand Down
2 changes: 2 additions & 0 deletions M2TWEOP Code/M2TWEOP library/luaPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ void luaPlugin::loadLuaScript(std::string& luaFilePath)
if (!fileRes.valid())
{
sol::error luaError = fileRes;
gameHelpers::logStringGame(luaError.what());
int result = MessageBoxA(nullptr, luaError.what(), "Lua syntax error!", defaultFlags);
console::handleMessageBoxResult(result);
return;
}
if (sol::protected_function_result result1 = fileRes(); !result1.valid())
{
sol::error luaError = result1;
gameHelpers::logStringGame(luaError.what());
int result = MessageBoxA(nullptr, luaError.what(), "Lua execution error!", defaultFlags);
console::handleMessageBoxResult(result);
return;
Expand Down
3 changes: 3 additions & 0 deletions M2TWEOP Code/M2TWEOP library/luaPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
#define SOL_LUAJIT 1
#include "lua/sol.hpp"
#include <string>
#include "gameHelpers.h"

#define tryLua(luaFunc) \
auto funcResult = luaFunc;\
UINT defaultFlags = MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION;\
if (!funcResult.valid())\
{\
sol::error luaError = funcResult;\
gameHelpers::logStringGame(luaError.what());\
int result = MessageBoxA(NULL, luaError.what(), "Lua exception!", defaultFlags);\
if (plugData::data.luaAll.checkVar("TERMINATE_AT_LUA_EXCEPTION", 1) == true)\
{\
Expand All @@ -32,6 +34,7 @@ UINT defaultFlags = MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION;\
if (!funcResult.valid())\
{\
sol::error luaError = funcResult;\
gameHelpers::logStringGame(luaError.what());\
int result = MessageBoxA(NULL, luaError.what(), "Lua exception!", defaultFlags);\
if (plugData::data.luaAll.checkVar("TERMINATE_AT_LUA_EXCEPTION", 1) == true)\
{\
Expand Down
1 change: 1 addition & 0 deletions M2TWEOP Code/M2TWEOP library/types/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if (!funcResult.valid())\
{\
sol::error luaError = funcResult;\
UINT defaultFlags = MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION;\
gameHelpers::logStringGame(luaError.what());\
int result = MessageBoxA(NULL, luaError.what(), "Lua exception!", defaultFlags);\
if (plugData::data.luaAll.checkVar("TERMINATE_AT_LUA_EXCEPTION", 1) == true)\
{\
Expand Down

0 comments on commit 402550b

Please sign in to comment.