友页是由 Pages 返回的特殊版本。其中包含的内容包括玩家的朋友的信息,并且有以下结构:
<tr><td><code>显示名称</code></td><td>字符串</td><td>朋好友的当前显示名称。</td></tr><tr><td><code>id</code></td><td>int64</td><td>朋好友的用户ID。</td></tr><tr><td><code>用户名</code></td><td>字符串</td><td>朋好友的用户名。</td></tr>
名称 | 类型 | 描述 |
请参阅“在玩家的朋友上迭代”的代码示例。
代码示例
Print Roblox Friends
local Players = game:GetService("Players")
local USERNAME = "Cozecant"
local function iterPageItems(pages)
return coroutine.wrap(function()
local pagenum = 1
while true do
for _, item in ipairs(pages:GetCurrentPage()) do
coroutine.yield(item, pagenum)
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
pagenum = pagenum + 1
end
end)
end
-- First, get the user ID of the player
local userId = Players:GetUserIdFromNameAsync(USERNAME)
-- Then, get a FriendPages object for their friends
local friendPages = Players:GetFriendsAsync(userId)
-- Iterate over the items in the pages. For FriendPages, these
-- are tables of information about the friend, including Username.
-- Collect each username in a table
local usernames = {}
for item, _pageNo in iterPageItems(friendPages) do
table.insert(usernames, item.Username)
end
print("Friends of " .. USERNAME .. ": " .. table.concat(usernames, ", "))
概要
属性
属性继承自Pages
方法
属性继承自Pages