Expand Lua libraries and enhance error recovery logic.
Added more Lua libraries to extend scripting capabilities within the application. Improved error handling by re-enabling the UI button and reloading the webview after a Lua script failure.
This commit is contained in:
+13
-1
@@ -246,7 +246,17 @@ void ToolboxWindow::run_lua(int id) {
|
|||||||
// Lambda-Funktion, um das Lua-Skript auszuführen
|
// Lambda-Funktion, um das Lua-Skript auszuführen
|
||||||
auto lua_task = [this, id]() {
|
auto lua_task = [this, id]() {
|
||||||
sol::state lua;
|
sol::state lua;
|
||||||
lua.open_libraries(sol::lib::base, sol::lib::os);
|
lua.open_libraries(sol::lib::base,
|
||||||
|
sol::lib::os,
|
||||||
|
sol::lib::string,
|
||||||
|
sol::lib::string,
|
||||||
|
sol::lib::coroutine,
|
||||||
|
sol::lib::package,
|
||||||
|
sol::lib::table,
|
||||||
|
sol::lib::math,
|
||||||
|
sol::lib::utf8,
|
||||||
|
sol::lib::coroutine,
|
||||||
|
sol::lib::io);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::string scriptPath = m_toolboxItems[id].lua_script;
|
std::string scriptPath = m_toolboxItems[id].lua_script;
|
||||||
@@ -255,6 +265,8 @@ void ToolboxWindow::run_lua(int id) {
|
|||||||
m_webview.reload();
|
m_webview.reload();
|
||||||
} catch (const sol::error& e) {
|
} catch (const sol::error& e) {
|
||||||
std::cerr << "Lua error: " << e.what() << std::endl;
|
std::cerr << "Lua error: " << e.what() << std::endl;
|
||||||
|
m_webview.execute("enableButtonByToolId({})",saucer::make_args(id));
|
||||||
|
m_webview.reload();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user