diff --git a/res/layouts/pages/main.xml b/res/layouts/pages/main.xml
index b1fab2c9e..b05ac7158 100644
--- a/res/layouts/pages/main.xml
+++ b/res/layouts/pages/main.xml
@@ -3,5 +3,5 @@
-
+
diff --git a/res/scripts/stdlib.lua b/res/scripts/stdlib.lua
index 83e75322f..06ba4f6e8 100644
--- a/res/scripts/stdlib.lua
+++ b/res/scripts/stdlib.lua
@@ -32,6 +32,7 @@ local function complete_app_lib(app)
local __core_reconfig_packs = core.reconfig_packs
local __app_tick = coroutine.yield
local __app_set_setting = app.set_setting
+ local __app_quit = app.quit
core.load_content = nil
core.reset_content = nil
@@ -51,7 +52,8 @@ local function complete_app_lib(app)
app.tick = __app_tick
local function call_in_app_script_co(func, ...)
- if coroutine.running() ~= __vc__app_script_coroutine then
+ local running = coroutine.running()
+ if not running or running ~= __vc__app_script_coroutine then
error("content must be reload in application script coroutine")
end
func(...)
@@ -88,15 +90,16 @@ local function complete_app_lib(app)
app.reconfig_packs(toadd, toremove)
end
- function app.quit()
- local tb = debug.get_traceback(1)
- local s = "app.quit() traceback:"
- for i, frame in ipairs(tb) do
- s = s .. "\n\t"..tb_frame_tostring(frame)
+ function app.quit(silent)
+ if not silent then
+ local tb = debug.get_traceback(1)
+ local s = "app.quit() traceback:"
+ for i, frame in ipairs(tb) do
+ s = s .. "\n\t"..tb_frame_tostring(frame)
+ end
+ debug.log(s)
end
- debug.log(s)
- core.quit()
- coroutine.yield()
+ __app_quit()
end
function app.sleep_until(predicate, max_ticks, max_time)
diff --git a/src/logic/scripting/lua/libs/libapp.cpp b/src/logic/scripting/lua/libs/libapp.cpp
index 4e8c6d9c4..b949adf72 100644
--- a/src/logic/scripting/lua/libs/libapp.cpp
+++ b/src/logic/scripting/lua/libs/libapp.cpp
@@ -208,6 +208,12 @@ static int l_open_url(lua::State* L) {
return 0;
}
+/// @brief Quit the game
+static int l_quit(lua::State*) {
+ engine->quit();
+ return 0;
+}
+
const luaL_Reg applib[] = {
{"get_version", lua::wrap},
{"is_content_loaded", lua::wrap},
@@ -224,6 +230,7 @@ const luaL_Reg applib[] = {
{"set_setting", lua::wrap},
{"str_setting", lua::wrap},
{"get_setting_info", lua::wrap},
+ {"quit", lua::wrap},
// for other functions see libcore.cpp and stdlib.lua
{nullptr, nullptr}
};
diff --git a/src/logic/scripting/lua/libs/libcore.cpp b/src/logic/scripting/lua/libs/libcore.cpp
index bef6f52a5..71a38d192 100644
--- a/src/logic/scripting/lua/libs/libcore.cpp
+++ b/src/logic/scripting/lua/libs/libcore.cpp
@@ -157,12 +157,6 @@ static int l_reconfig_packs(lua::State* L) {
return 0;
}
-/// @brief Quit the game
-static int l_quit(lua::State*) {
- engine->quit();
- return 0;
-}
-
static int l_blank(lua::State*) {
return 0;
}
@@ -205,7 +199,6 @@ const luaL_Reg corelib[] = {
{"close_world", lua::wrap},
{"delete_world", lua::wrap},
{"reconfig_packs", lua::wrap},
- {"quit", lua::wrap},
{"capture_output", lua::wrap},
{nullptr, nullptr}
};