Lua:os.gethostname()

This commit is contained in:
2026-02-03 23:41:11 +08:00
parent 1933eee16b
commit 8c0d3a7cb8
2 changed files with 11 additions and 8 deletions

View File

@@ -33,17 +33,12 @@ namespace CMLeonOS
// 创建全局CosmosVFS实例 // 创建全局CosmosVFS实例
public static Sys.FileSystem.CosmosVFS fs = new Sys.FileSystem.CosmosVFS(); public static Sys.FileSystem.CosmosVFS fs = new Sys.FileSystem.CosmosVFS();
public static Shell shell;
private Shell shell; public static UserSystem userSystem;
private UserSystem userSystem;
// 修复模式变量(硬编码,用于控制是否启用修复模式)
public static bool FixMode = false; public static bool FixMode = false;
// 系统启动时间用于uptime命令
public static DateTime SystemStartTime; public static DateTime SystemStartTime;
// 网络配置信息
public static Cosmos.HAL.NetworkDevice NetworkDevice = null; public static Cosmos.HAL.NetworkDevice NetworkDevice = null;
public static string IPAddress = "Unknown"; public static string IPAddress = "Unknown";

View File

@@ -13,6 +13,7 @@ namespace UniLua
{ {
#if !UNITY_WEBPLAYER #if !UNITY_WEBPLAYER
new NameFuncPair("clock", OS_Clock), new NameFuncPair("clock", OS_Clock),
new NameFuncPair("gethostname", OS_Gethostname),
#endif #endif
}; };
@@ -23,7 +24,14 @@ namespace UniLua
#if !UNITY_WEBPLAYER #if !UNITY_WEBPLAYER
private static int OS_Clock( ILuaState lua ) private static int OS_Clock( ILuaState lua )
{ {
lua.PushNumber(0); //TO PLUG lua.PushNumber(0);
return 1;
}
private static int OS_Gethostname( ILuaState lua )
{
string hostname = CMLeonOS.Kernel.userSystem?.GetHostname() ?? "Not set";
lua.PushString(hostname);
return 1; return 1;
} }
#endif #endif