mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
Lua增加更多函数
This commit is contained in:
@@ -2,8 +2,10 @@
|
|||||||
namespace UniLua
|
namespace UniLua
|
||||||
{
|
{
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System;
|
||||||
using CMLeonOS;
|
using CMLeonOS;
|
||||||
using Sys = Cosmos.System;
|
using Sys = Cosmos.System;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
internal class LuaOSLib
|
internal class LuaOSLib
|
||||||
{
|
{
|
||||||
@@ -24,6 +26,9 @@ namespace UniLua
|
|||||||
new NameFuncPair("executefile", OS_Executefile),
|
new NameFuncPair("executefile", OS_Executefile),
|
||||||
new NameFuncPair("reboot", OS_Reboot),
|
new NameFuncPair("reboot", OS_Reboot),
|
||||||
new NameFuncPair("shutdown", OS_Shutdown),
|
new NameFuncPair("shutdown", OS_Shutdown),
|
||||||
|
new NameFuncPair("sleep", OS_Sleep),
|
||||||
|
new NameFuncPair("beep", OS_Beep),
|
||||||
|
new NameFuncPair("clear", OS_Clear),
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -127,6 +132,35 @@ namespace UniLua
|
|||||||
lua.PushBoolean(true);
|
lua.PushBoolean(true);
|
||||||
return 1;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user