SInventory
ClientPlayer
On this classAuthorize
Members 7
| Function | Authorize | Requests access to inventory functions, must be called prior to attempting to access inventory. |
| Function | CountCopiesOfItem | – |
| Function | AddToHotbar | Adds the first found instance of itemID to the players hotbar entry at slot 'index'. |
| Function | RemoveFromHotbar | Remove item at slot index from Hotbar |
| Function | RequestRefresh | Forces a check for external changes to the users inventory, can only be called once every 60 seconds |
| Property | Authorized | Returns true if player has accepted access authorization request to his inventory |
| Property | Items | Returns the array of the users current inventory items |
Functions
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'.
Parameters
| Name | Type | Default |
|---|---|---|
| onAuthorized | Closure | null |
| onRejected | Closure | null |
Returns
void
Example
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)
Parameters
| Name | Type | Default |
|---|---|---|
| itemID | int | – |
Returns
int
Example
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'.
Parameters
| Name | Type | Default |
|---|---|---|
| index | int | – |
| itemID | int | – |
Returns
void
Example
Lua
Space.Inventory.AddToHotbar(2, 23423523)
RemoveFromHotbar
void RemoveFromHotbar(int index)
Remove item at slot index from Hotbar
Parameters
| Name | Type | Default |
|---|---|---|
| index | int | – |
Returns
void
Example
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
Returns
void
Example
Lua
Space.Inventory.RequestRefresh()
Properties
AuthorizedRead only
bool Authorized {get; }
Returns true if player has accepted access authorization request to his inventory
Example
Lua
isAuthorized = Space.Inventory.Authorized
ItemsRead only
Returns the array of the users current inventory items
Example
Lua
invItems = Space.Inventory.Items



