From 9d4a48096e6c4003c4f0a88a4cb23df812c2b26b Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 7 Jan 2026 00:07:17 +0300 Subject: [PATCH] feat: disable app.reset_content out of app script coroutine --- res/scripts/stdlib.lua | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/res/scripts/stdlib.lua b/res/scripts/stdlib.lua index 7aabc20c7..ac073df25 100644 --- a/res/scripts/stdlib.lua +++ b/res/scripts/stdlib.lua @@ -31,10 +31,14 @@ function core.set_setting(name, value, ...) end local __vc__app_script_coroutine -local __core_load_content = core.load_content -core.load_content = nil local function complete_app_lib(app) + local __core_load_content = core.load_content + local __core_reset_content = core.reset_content + local __app_tick = coroutine.yield + core.load_content = nil + core.reset_content = nil + app.sleep = sleep app.script = __VC_SCRIPT_NAME app.new_world = core.new_world @@ -46,21 +50,27 @@ local function complete_app_lib(app) app.reconfig_packs = core.reconfig_packs app.get_setting = core.get_setting app.set_setting = core.set_setting - app.tick = function() - coroutine.yield() - end - - local __app_tick = app.tick + app.tick = __app_tick app.get_version = core.get_version app.get_setting_info = core.get_setting_info - app.load_content = function() + + local function require_app_script_co() if coroutine.running() ~= __vc__app_script_coroutine then error("content must be reload in application script coroutine") end + end + + app.load_content = function() + require_app_script_co() __core_load_content() __app_tick() end - app.reset_content = core.reset_content + app.reset_content = function() + require_app_script_co() + __core_reset_content() + __app_tick() + end + app.is_content_loaded = core.is_content_loaded app.set_title = core.set_title