From 79853052ae86b8f6d2a9c3d4aaebe22a294c3f74 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Wed, 4 Feb 2026 01:21:30 +0800 Subject: [PATCH] =?UTF-8?q?Lua=E5=A2=9E=E5=8A=A0=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UniLua/LuaOsLib.cs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/UniLua/LuaOsLib.cs b/UniLua/LuaOsLib.cs index cf60263..3de6884 100644 --- a/UniLua/LuaOsLib.cs +++ b/UniLua/LuaOsLib.cs @@ -2,8 +2,10 @@ namespace UniLua { using System.Diagnostics; + using System; using CMLeonOS; using Sys = Cosmos.System; + using System.Threading; internal class LuaOSLib { @@ -24,6 +26,9 @@ namespace UniLua new NameFuncPair("executefile", OS_Executefile), new NameFuncPair("reboot", OS_Reboot), new NameFuncPair("shutdown", OS_Shutdown), + new NameFuncPair("sleep", OS_Sleep), + new NameFuncPair("beep", OS_Beep), + new NameFuncPair("clear", OS_Clear), #endif }; @@ -127,6 +132,35 @@ namespace UniLua lua.PushBoolean(true); return 1; } + + private static int OS_Sleep( ILuaState lua ) + { + double seconds = lua.L_CheckNumber(1); + if (seconds < 0) + { + lua.PushNil(); + return 1; + } + + int milliseconds = (int)(seconds * 1000); + Thread.Sleep(milliseconds); + lua.PushBoolean(true); + return 1; + } + + private static int OS_Beep( ILuaState lua ) + { + Console.Beep(); + lua.PushBoolean(true); + return 1; + } + + private static int OS_Clear( ILuaState lua ) + { + Console.Clear(); + lua.PushBoolean(true); + return 1; + } #endif } }