调用方式
addon.Platform:GetGroupMembership(raidOnly)
可直接通过 addon 使用,无需依赖项。
作用
在已识别的客户端系列上读取公开的队伍成员身份。未知客户端不受支持。raidOnly 为 true 时检查 IsInRaid;为 false 或 nil 时使用原生默认的队伍类别检查 IsInGroup。可读的 false 结果保持为 false。缺失、失败、格式错误或受限的观测会返回 nil 及原因。
参数
| 名称 | 类型 | 作用 |
|---|---|---|
self | RMPlatform | Rotation Master 平台适配器(使用冒号调用时隐含传入)。 |
raidOnly | boolean | nil | 为 true 时请求团队成员身份;为 false 或 nil 时请求任何队伍成员身份。 |
返回值
| 1 | boolean | nil | 观测到的成员身份;不可用时为 nil。 |
|---|---|---|
| 2 | string | nil | 结果为 nil 时的验证或可用性原因。 |
版本
内置辅助函数在每个版本上都会注册。不同的是它们读取的游戏 API;某个 API 缺失时,辅助函数会改用后备方案,或返回 nil 并附上原因。
- 该版本不可用(原因见提示)
- 仅在暴雪的弃用兼容层开启时
秘密值(正式服和永久服)
在正式服和永久服上,游戏交给插件的是秘密值。此辅助函数会检查它读取的内容(addon.Platform:CanReadValue),遇到无法比较的秘密值时返回 nil 并附上原因(例如 restricted-value),而不是返回该秘密值。请将 nil 视为不可用,而不是假。
示例
local grouped = addon.Platform:GetGroupMembership(false)
local raid = addon.Platform:GetGroupMembership(true)
if grouped == nil or raid == nil then return nil end
return grouped and not raid -- in a party, not a raid源码
Platform/groups.lua,第 20 行。在游戏中为只读;“复制”会生成一份可编辑的副本。
Platform.groups.GetGroupMembership(self, raidOnly)
if not self:CanReadValue(raidOnly) then return nil,'restricted-value' end
if raidOnly~=nil and type(raidOnly)~='boolean' then return nil,'invalid-group-query' end
if self:GetClientFamily()=='unknown' then return nil,'unsupported-client' end
local fn
if raidOnly then fn=IsInRaid else fn=IsInGroup end
if type(fn)~='function' then return nil,'missing-api' end
local ok,member=pcall(fn)
if not ok then return nil,'api-error' end
if not self:CanReadValue(member) then return nil,'restricted-value' end
if member==nil then return nil,'group-data-unavailable' end
if type(member)~='boolean' then return nil,'invalid-api-result' end
return member




