一个 tuple 是一列值。Roblox 引擎 API 方法 和 回调 中的许多方法和回调接受和返回多个值,但 API 参考书说“ tuple ”而不是这些值。
参数
如果 方法 或 回调 接受 tuple 作为参数,那么它接受多个值。例如,API 参考显示,BindableFunction:Invoke() 方法接受一个 "Tuple" 作为参数,因此接受多个参数。
BindableFunction:Invoke(1, true, "string", Vector3.new(0, 0, 0))
返回
如果 方法 或 回调 返回 tuple,那么它返回多元组值。例如,API 参考显示,Players:GetUserThumbnailAsync() 方法返回一个 "Tuple",因此返回多个值。第一个返回值是内容 URL,第二个是 boolean。
local Players = game:GetService("Players")local userId = 156 -- 建筑工local thumbType = Enum.ThumbnailType.HeadShotlocal thumbSize = Enum.ThumbnailSize.Size420x420local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)print(content, isReady) -- rbxthumb://type=AvatarHeadShot&id=156&w=420&h=420 true