useritemmanager - TogetherGames/Public-Corona-Lua GitHub Wiki

UserItemManager

together.UserItemManager

Overview

The UserItemManager is used for fetching and finding items that exist for the current user.


Members

table UserItems

Stores all the UserItems contained in the Manager.


Methods


Add()

Adds a UserItem to the internally managed list without persistence.

Note
This method is deprecated

Returns void
Syntax
UserItemManager:Add( userItem )
Parameters

TogetherUserItem userItem

Instance of a UserItem to add internally

--------------------------------------------------------------------------------

FindByUserItemID()

Finds the UserItem with the specified UserItemID if it exists, otherwise returns nil.

Syntax
UserItemManager:FindByUserItemID( userItemID )
Parameters

number userItemID

The ID of the UserItem to find

--------------------------------------------------------------------------------

GetCount()

Gets the number of UserItems currently managed internally.

Returns number
Syntax
UserItemManager:GetCount(  )

Get()

Gets the UserItem at the specified index if it exists, otherwise returns nil.

Syntax
UserItemManager:Get( index )
Parameters

number index

The index of the UserItem to retrieve.

--------------------------------------------------------------------------------

IndexOf()

Returns the index of the specified UserItem if it exists, otherwise returns nil.

Returns number
Syntax
UserItemManager:IndexOf( userItem )
Parameters

TogetherUserItem userItem

Instance of the UserItem to find the index of

--------------------------------------------------------------------------------

IndexOfByUserItemID()

Returns the index of the UserItem with the specified UserItemID if it exists, otherwise returns -1.

Returns number
Syntax
UserItemManager:IndexOfByUserItemID( userItemID )
Parameters

number userItemID

The ID of the UserItem to find the index of

--------------------------------------------------------------------------------

Remove()

Removes a UserItem from the internally managed list. This does not delete the user item from the user's account persistently.

Note
This method is deprecated

Returns void
Syntax
UserItemManager:Remove( index )
Parameters

number index

The index of the UserItem to remove internally

--------------------------------------------------------------------------------

Award()

Awards a UserItem. Upon success, this automatically updates the internal list.

Note
Rooms are deprecated and the roomID has no effect at this time

Returns void
Syntax
UserItemManager:Award( itemID, roomID, userItemProperties, callbackFunc )
Parameters

number itemID

The ID of the Item to award.

[number](#) roomID

The ID of the Room the UserItem is being awarded in. Pass 0.

[PropertyCollection](./propertycollection) userItemProperties

The properties to assign to the UserItem. Pass nil to assign no properties.

[function](#) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

Create()

Creates a UserItem.

Note
Rooms are deprecated and the roomID has no effect at this time

Returns void
Syntax
UserItemManager:Create( itemID, roomID, userItemProperties, callbackFunc )
Parameters

number itemID

The ID of the Item to create a UserItem from.

[number](#) roomID

The ID of the Room the UserItem is being awarded in. Pass 0.

[PropertyCollection](./propertycollection) userItemProperties

The properties to assign to the UserItem. Pass nil to assign no properties.

[function](#) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

Delete()

Deletes a UserItem. Upon success, this automatically updates the internal list.

Returns void
Syntax
UserItemManager:Delete( userItemID, callbackFunc )
Parameters

number userItemID

The ID of the UserItem to delete.

[function](#) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

GetAll()

Gets all UserItems assigned to the User. Upon success, this automatically updates the internal list.

Returns void
Syntax
UserItemManager:GetAll( callbackFunc )
Parameters

function callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

Purchase()

Purchases a UserItem. Upon success, this automatically updates the internal list.

Note
Rooms are deprecated and the roomID has no effect at this time

Returns void
Syntax
UserItemManager:Purchase( itemID, roomID, userItemProperties, callbackFunc )
Parameters

number itemID

The ID of the Item to purchase.

[number](#) roomID

The ID of the Room the UserItem is being awarded in. Pass 0.

[PropertyCollection](./propertycollection) userItemProperties

The properties to assign to the UserItem. Pass nil to assign no properties.

[function](#) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

Sell()

Sells a UserItem. Upon success, this automatically updates the internal list.

Returns void
Syntax
UserItemManager:Sell( userItemID, callbackFunc )
Parameters

number userItemID

The ID of the UserItem to sell.

[function](#) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------
⚠️ **GitHub.com Fallback** ⚠️