remove core.quit add 'silent' argument to app.quit

This commit is contained in:
MihailRis 2026-01-07 19:37:57 +03:00
parent 24f867dbac
commit 9af675611f
4 changed files with 20 additions and 17 deletions

View file

@ -3,5 +3,5 @@
<button onclick='menu.page="scripts"'>@Scripts</button>
<button onclick='menu.page="settings"'>@Settings</button>
<button onclick='menu.page="content_menu"'>@Content</button>
<button onclick='core.quit()'>@Quit</button>
<button onclick='app.quit(true)'>@Quit</button>
</panel>

View file

@ -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)

View file

@ -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<l_get_version>},
{"is_content_loaded", lua::wrap<l_is_content_loaded>},
@ -224,6 +230,7 @@ const luaL_Reg applib[] = {
{"set_setting", lua::wrap<l_set_setting>},
{"str_setting", lua::wrap<l_str_setting>},
{"get_setting_info", lua::wrap<l_get_setting_info>},
{"quit", lua::wrap<l_quit>},
// for other functions see libcore.cpp and stdlib.lua
{nullptr, nullptr}
};

View file

@ -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<l_close_world>},
{"delete_world", lua::wrap<l_delete_world>},
{"reconfig_packs", lua::wrap<l_reconfig_packs>},
{"quit", lua::wrap<l_quit>},
{"capture_output", lua::wrap<l_capture_output>},
{nullptr, nullptr}
};