SInventory
客户端玩家
成员 7
| 函数 | Authorize | Requests access to inventory functions, must be called prior to attempting to access inventory. |
| 函数 | CountCopiesOfItem | – |
| 函数 | AddToHotbar | Adds the first found instance of itemID to the players hotbar entry at slot 'index'. |
| 函数 | RemoveFromHotbar | Remove item at slot index from Hotbar |
| 函数 | RequestRefresh | Forces a check for external changes to the users inventory, can only be called once every 60 seconds |
| 属性 | Authorized | Returns true if player has accepted access authorization request to his inventory |
| 属性 | Items | Returns the array of the users current inventory items |
函数
Authorize
void Authorize(Closure onAuthorized = null, Closure onRejected = null)
Requests access to inventory functions, must be called prior to attempting to access inventory. As soon as the player has accepted the request, the Authorized attribute will be 'true'.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| onAuthorized | Closure | null |
| onRejected | Closure | null |
返回值
void
示例
Lua
Space.Inventory.Authorize()
--or
Space.Inventory.Authorize(onAuth, onRej)
Lua
--this script shows you how to use this function to take authorization and immediately
--take action based on the result all in a single prompt (a click in this case)
function ifno()
Space.Log("not authorized")
end
function ifyes()
Space.Log("authorized")
--your next steps go here
end
function click()
Space.Inventory.Authorize(ifyes,ifno)
end
Space.Host.ExecutingObject.AddClickable()
Space.Host.ExecutingObject.Clickable.OnClick(click)
CountCopiesOfItem
int CountCopiesOfItem(int itemID)
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| itemID | int | – |
返回值
int
示例
Lua
numOfCopies = Space.Inventory.CountCopiesOfItem(38384839)
AddToHotbar
void AddToHotbar(int index, int itemID)
Adds the first found instance of itemID to the players hotbar entry at slot 'index'.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| index | int | – |
| itemID | int | – |
返回值
void
示例
Lua
Space.Inventory.AddToHotbar(2, 23423523)
RemoveFromHotbar
void RemoveFromHotbar(int index)
Remove item at slot index from Hotbar
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| index | int | – |
返回值
void
示例
Lua
Space.Inventory.RemoveFromHotbar(2)
RequestRefresh
void RequestRefresh()
Forces a check for external changes to the users inventory, can only be called once every 60 seconds
返回值
void
示例
Lua
Space.Inventory.RequestRefresh()
属性
Authorized只读
bool Authorized {get; }
Returns true if player has accepted access authorization request to his inventory
示例
Lua
isAuthorized = Space.Inventory.Authorized
Items只读
Returns the array of the users current inventory items
示例
Lua
invItems = Space.Inventory.Items



