From b1e7f6c8d35dcbee85b878361643dead960776ce Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Sun, 14 Sep 2025 22:21:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(installer):=20=E6=9B=B4=E6=96=B0=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=99=A8=E7=89=88=E6=9C=AC=E8=87=B31.0.3=20Beta=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(appgui_demo): 使用安全的事件拉取函数替换os.pullEvent --- .../lua/rom/programs/appgui_demo.lua | 23 +++++++++++++++---- installer.lua | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/data/computercraft/lua/rom/programs/appgui_demo.lua b/data/computercraft/lua/rom/programs/appgui_demo.lua index cd0707b..8fe8acf 100644 --- a/data/computercraft/lua/rom/programs/appgui_demo.lua +++ b/data/computercraft/lua/rom/programs/appgui_demo.lua @@ -20,8 +20,12 @@ print("The bottom bar shows the status information.") print() print("Press any key to see custom colors...") --- Wait for a key press -os.pullEvent("key") +-- Wait for a key press using a safe event pulling function +local pullEventFunc = os.pullEvent or os.pullEventRaw +if not pullEventFunc then + error("No valid event pulling function found") +end +local event, key = table.unpack({pullEventFunc("key")}) -- Clear the screen and redraw with custom colors term.clear() @@ -35,8 +39,12 @@ print("Top bar: Yellow text on Red background") print() print("Press any key to continue...") --- Wait for a key press -os.pullEvent("key") +-- Wait for a key press using a safe event pulling function +local pullEventFunc = os.pullEvent or os.pullEventRaw +if not pullEventFunc then + error("No valid event pulling function found") +end +local event, key = table.unpack({pullEventFunc("key")}) -- Clear the screen and draw both top and bottom bars term.clear() @@ -53,7 +61,12 @@ print("Press Q to exit this demo.") -- Main loop to handle key presses while true do - local event, key = os.pullEvent("key") + -- Use a safe event pulling function + local pullEventFunc = os.pullEvent or os.pullEventRaw + if not pullEventFunc then + error("No valid event pulling function found") + end + local event, key = table.unpack({pullEventFunc("key")}) if key == 16 then -- Q key break end diff --git a/installer.lua b/installer.lua index b3bed1e..ad06e64 100644 --- a/installer.lua +++ b/installer.lua @@ -1,5 +1,5 @@ -- LeonOS installer -local INSTALLER_VERSION = "1.0.3 Beta 6" +local INSTALLER_VERSION = "1.0.3 Beta 7" local DEFAULT_ROM_DIR = "/leonos" print("Start loading LeonOS installer ("..INSTALLER_VERSION..")...")