增加更多Lua功能

This commit is contained in:
2026-02-04 01:55:14 +08:00
parent 79853052ae
commit 5a07c7a133
3 changed files with 136 additions and 7 deletions

View File

@@ -29,6 +29,8 @@ namespace UniLua
new NameFuncPair("sleep", OS_Sleep),
new NameFuncPair("beep", OS_Beep),
new NameFuncPair("clear", OS_Clear),
new NameFuncPair("getusername", OS_Getusername),
new NameFuncPair("isadmin", OS_Isadmin),
#endif
};
@@ -161,6 +163,20 @@ namespace UniLua
lua.PushBoolean(true);
return 1;
}
private static int OS_Getusername( ILuaState lua )
{
string username = CMLeonOS.Kernel.userSystem?.CurrentUsername ?? "Not logged in";
lua.PushString(username);
return 1;
}
private static int OS_Isadmin( ILuaState lua )
{
bool isAdmin = CMLeonOS.Kernel.userSystem?.CurrentUserIsAdmin ?? false;
lua.PushBoolean(isAdmin);
return 1;
}
#endif
}
}