diff --git a/res/scripts/stdlib.lua b/res/scripts/stdlib.lua index 9ee20241..67cdd0fe 100644 --- a/res/scripts/stdlib.lua +++ b/res/scripts/stdlib.lua @@ -37,7 +37,10 @@ local function complete_app_lib(app) app.tick = coroutine.yield app.get_version = core.get_version app.get_setting_info = core.get_setting_info - app.load_content = core.load_content + app.load_content = function() + core.load_content() + app.tick() + end app.reset_content = core.reset_content app.is_content_loaded = core.is_content_loaded @@ -416,7 +419,18 @@ end function start_coroutine(chunk, name) local co = coroutine.create(function() - local status, error = xpcall(chunk, __vc__error) + local status, error = xpcall(chunk, function(...) + gui.alert(debug.traceback(), function() + if world.is_open() then + __vc_app.close_world() + else + __vc_app.reset_content() + menu:reset() + menu.page = "main" + end + end) + return ... + end) if not status then debug.error(error) end diff --git a/src/graphics/ui/gui_util.cpp b/src/graphics/ui/gui_util.cpp index b84dcfd0..04026132 100644 --- a/src/graphics/ui/gui_util.cpp +++ b/src/graphics/ui/gui_util.cpp @@ -34,13 +34,14 @@ void guiutil::alert( auto panel = std::make_shared(glm::vec2(500, 300), glm::vec4(4.0f), 4.0f); panel->setColor(glm::vec4(0.0f, 0.0f, 0.0f, 0.5f)); - auto menu = engine.getGUI()->getMenu(); - runnable on_hidden_final = [on_hidden, menu, &engine]() { - menu->removePage(""); + auto menuPtr = engine.getGUI()->getMenu(); + auto& menu = *menuPtr; + runnable on_hidden_final = [on_hidden, &menu, &engine]() { + menu.removePage(""); if (on_hidden) { on_hidden(); } else { - menu->back(); + menu.back(); } }; @@ -50,21 +51,21 @@ void guiutil::alert( panel->add(label); panel->add(std::make_shared