Breakroom is now Sinewave Campus. Book a meeting

SInventory

ClientJoueur
Dans cette classeAuthorize
  1. Fonctions
  2. Authorize
  3. CountCopiesOfItem
  4. AddToHotbar
  5. RemoveFromHotbar
  6. RequestRefresh
  7. Propriétés
  8. Authorized
  9. Items
Membres 7
FonctionAuthorizeRequests access to inventory functions, must be called prior to attempting to access inventory.
FonctionCountCopiesOfItem–
FonctionAddToHotbarAdds the first found instance of itemID to the players hotbar entry at slot 'index'.
FonctionRemoveFromHotbarRemove item at slot index from Hotbar
FonctionRequestRefreshForces a check for external changes to the users inventory, can only be called once every 60 seconds
PropriétéAuthorizedReturns true if player has accepted access authorization request to his inventory
PropriétéItemsReturns the array of the users current inventory items

Fonctions​

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'.

Paramètres

NomTypeValeur par défaut
onAuthorizedClosurenull
onRejectedClosurenull

Valeurs de retour

void

Exemple

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)

Paramètres

NomTypeValeur par défaut
itemIDint–

Valeurs de retour

int

Exemple

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'.

Paramètres

NomTypeValeur par défaut
indexint–
itemIDint–

Valeurs de retour

void

Exemple

Lua
Space.Inventory.AddToHotbar(2, 23423523)

RemoveFromHotbar​

void RemoveFromHotbar(int index)

Remove item at slot index from Hotbar

Paramètres

NomTypeValeur par défaut
indexint–

Valeurs de retour

void

Exemple

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

Valeurs de retour

void

Exemple

Lua
Space.Inventory.RequestRefresh()

Propriétés​

AuthorizedLecture seule​

bool Authorized {get; }

Returns true if player has accepted access authorization request to his inventory

Exemple

Lua
isAuthorized = Space.Inventory.Authorized

ItemsLecture seule​

SInventoryItem[] Items {get; }

Returns the array of the users current inventory items

Exemple

Lua
invItems = Space.Inventory.Items