broken
This commit is contained in:
+14
-7
@@ -241,12 +241,22 @@ void ToolboxWindow::fillToolboxMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
void ToolboxWindow::run_lua(int id) {
|
||||
extern "C" int luaopen_moonfltk(lua_State* L);
|
||||
|
||||
// Lambda-Funktion, um das Lua-Skript auszuführen
|
||||
void ToolboxWindow::run_lua(int id) {
|
||||
auto lua_task = [this, id]() {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base, sol::lib::os);
|
||||
lua.open_libraries(sol::lib::base, sol::lib::os, sol::lib::utf8, sol::lib::package);
|
||||
|
||||
// Hier machen wir das statisch eingebundene Modul 'moonfltk' für require verfügbar:
|
||||
lua["package"]["preload"]["moonfltk"] = luaopen_moonfltk;
|
||||
|
||||
|
||||
// Teste, ob require nun verfügbar ist:
|
||||
sol::object req = lua["require"];
|
||||
if (!req.is<sol::function>()) {
|
||||
std::cerr << "require is not available!" << std::endl;
|
||||
}
|
||||
|
||||
try {
|
||||
std::string scriptPath = m_toolboxItems[id].lua_script;
|
||||
@@ -258,11 +268,8 @@ void ToolboxWindow::run_lua(int id) {
|
||||
}
|
||||
};
|
||||
|
||||
// Erstellen und starten des Threads
|
||||
std::thread lua_thread(lua_task);
|
||||
|
||||
// Optional: Warten auf den Abschluss des Threads
|
||||
lua_thread.detach(); // Falls Sie den Thread nicht blockieren wollen
|
||||
lua_thread.detach();
|
||||
|
||||
std::cout << "Lua-Skript wurde gestartet." << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user