User inventory. UserCore subclass. Items and inventory are described in detail in Items and Bundles and Users articles.

Constructor

Methods

add (item:ItemProtoClass, ?amount:Int):String

Adds item to inventory with a given amount. Returns operation error code (reserved for later use, at the moment it is always ok). This is a low-level operation that does not do any checks. A new item is always created in inventory.

Parameters:

item

Item prototype.

amount

Item amount.

Returns:

Operation error code. ok - operation successful.

clear ():Void

Clear this inventory.

decrease (item:ItemProtoClass, ?amount:Int):Bool

Decreases item amount by a given amount.

Parameters:

item

Item prototype.

amount

(optional) Amount to remove. Equals 1 by default.

Returns:

True, if the operation was successful. False, if the item was not found.

decreaseStringID (sid:String, ?amount:Int):Bool

Decreases item amount by a given amount. Item is chosen by its string ID.

Parameters:

sid

Item string ID. If multiple items have the same string ID, the result is unpredictable.

amount

(optional) Amount to remove. Equals 1 by default.

Returns:

True, if the operation was successful. False, if the item was not found.

dump (lang:String):List<Dynamic>

Dumps inventory items parameters to a list for client response.

Parameters:

lang

Client language.

Returns:

A list of anonymous objects with item parameters.

get (id:Int):ItemProtoClass

Returns item by its ID.

Parameters:

id

Item ID.

Returns:

Item. Returns null, if no such item is in inventory.

getAmount (item:ItemProtoClass):Int

Returns item amount.

Parameters:

id

Item prototype.

Returns:

Item amount. Returns 0, if no such item is in inventory.

getByStringID (sid:String):ItemProtoClass

Returns item by its string ID.

Parameters:

sid

Item string ID.

Returns:

Item. Returns null, if no such item is in inventory.

inline getList ():Array<Item>

Returns the list of items from block.

Returns:

Array of list items.

has (item:ItemProtoClass):Bool

Returns true, if this inventory contains this item.

Parameters:

item

Item prototype.

Returns:

True, if the inventory contains this item. False otherwise.

hasStringID (sid:String):Bool

Returns true, if this inventory contains an item with this string ID.

Parameters:

sid

Item string ID.

Returns:

True, if the inventory contains this item. False otherwise.

put (item:ItemProtoClass, ?amount:Int):String

Puts an item in inventory with a given amount. Supports item bundles ("bundleID" item attribute). Returns different operation error codes. Multiple stacks of the same item are not supported.

Parameters:

item

Item prototype.

amount

Item amount to put in inventory.

Returns:

Operation error code. maxAmountReached - maximum amount for this item is reached. Maximum amount is stored in maxAmount item attribute (unlimited by default). ok - operation successful.

dynamic putPre (item:ItemProtoClass, amount:Int):Bool

This method is called before putting item in inventory. If it returns false, the item is not put into inventory, but InventoryCore.put() still returns "ok" error code.

Parameters:

item

Item prototype.

amount

Item amount.

Returns:

True, if the setting operation should be allowed. False otherwise.

remove (item:ItemProtoClass):String

Removes an item from inventory. Returns ok, if the operation was successful.

Parameters:

item

Item prototype.

Returns:

Operation error code. ok - operation successful.

removeAmount (s:String, amount:Int):Void

Removes that amount of given item.

Parameters:

s

Item string ID.

amount

Amount to remove.