ITEM

Item Metatable The ITEM metatable is a bit weird, having some quirks.

Typically, functions which relate to generating the items / setting data (New, SetDescription) are in UpperCamelCase. However, functions which relate to the operation of the item (canUse, onDrop), are in lowerCamelCase.

Functions

AddLocalisationValue(field, value)

View source »

Add a localisation variable to a given field. This is fed into L.

Parameters

  • field string

    The name of the field to add the localisation value for.

  • value

    Value to pass to L.

Returns

  • ITEM

AutoFunction(name, key)

View source »

Creates an automatically named accessor function pair. It also returns a single param function, which sets a default value and returns the item.

Parameters

  • name string

    Function Key (Resolves to [GS]et).

  • key string

    Internal key to set.

Returns

  • function

Example Usage

local setDefault = ITEM:AutoFunction("SpecialValue", "internal_flag")
-- This creates ITEM:SetSpecialValue() and ITEM:GetSpecialValue().
-- Calling this function sets a value on ITEM.internal_flag.
-- Calling setDefault, sets the value now, returning the item. This is useful for chaining.
ITEM:AutoFunction("SomeValue", "this_defaults_to_false")(false)

See Also

AutoLocalise()

View source »

Fill in as many fields as possible with localisation.

Returns

  • ITEM

AutoRegister()

View source »

Register an item, attempting to pull the item's UID from the file name.

See Also

Clone()

View source »

Clone an item. Returns a new ITEM, with base set to the first item.

Returns

  • ITEM

GetBatch()

View source »

Gets an item's batch

Returns

  • int

    Batch Size

GetCategory()

View source »

Gets an item's category

Returns

GetCategory()

View source »

Gets an item's category

Returns

See Also

GetCost()

View source »

Gets the Market Cost.

Returns

  • int

    Item's Cost

GetDesc()

View source »

Alias of ITEM:GetDescription

Returns

See Also

GetDescription()

View source »

Gets an item's description

Returns

GetInitialStock()

View source »

Gets the initial dynamic economy stock for this item.

Returns

  • int

    Stock

GetModel()

View source »

Get an item's skin.

Returns

  • int

    Model skin index.

GetModel()

View source »

Get an item's model.

Returns

GetName()

View source »

Gets an item's name.

Returns

GetPlural()

View source »

Gets an item plural.

Returns

GetPrice()

View source »

Alias of ITEM:GetCost

Returns

  • int

    Item's Cost

See Also

GetSize()

View source »

Gets an item's inventory size.

Returns

  • int

    Size

GetStore()

View source »

Get the item can be bought in the store.

Returns

  • bool

    Buyable status.

GetStoreModel()

View source »

Get an item's model in the market / inventory.

Returns

GetStoreSkin()

View source »

Get an item's skin in the store page.

Returns

  • int

    Model skin index.

GetSupporter()

View source »

Gets if the item is for supporters.

Returns

  • bool

    If supporter is required.

GetSupporterPlus()

View source »

Gets if the item is for supporter plus.

Returns

  • bool

    If supporter plus is required.

GetTeam()

View source »

Gets an item's team

Returns

  • int

    Item's Team.

Merge(data)

View source »

Merge a table of data into the item.

Parameters

  • data tab

    Key/Value pairs of data.

Returns

  • ITEM

New(base, data)

View source »

Create a new item.

Parameters

  • base string

    UniqueID of the baseclass.

  • data tab

    Optional data to fill into the item.

Returns

  • ITEM

Register(id)

View source »

Register an item. This must be the last call in an item chain, as it does processing on the item.

Parameters

  • id string optional

    UniqueID to set, not required if set prior.

Set(name, value)

View source »

Set a single key on the item.

Parameters

  • value

    Value to set.

Returns

  • ITEM

SetBatch(data)

View source »

Sets the number of items created in a press of the manufacture button.

Parameters

  • data int

    Batch

Returns

  • ITEM

SetCat(data)

View source »

Alias of ITEM:SetCategory

Parameters

Returns

  • ITEM

See Also

SetCategory(data)

View source »

Sets the category of an item.

Parameters

Returns

  • ITEM

SetCost(cost)

View source »

Sets the Market Cost.

Parameters

  • cost int

    Cost.

Returns

  • ITEM

SetData(name, value)

Deprecated

This function is deprecated and may be removed in a future version.

View source »

Set a single key on the item.

Parameters

  • value

    Value to set.

Returns

  • ITEM

See Also

SetDesc(data)

View source »

Alias of ITEM:SetDescription

Parameters

Returns

  • ITEM

See Also

SetDescription(data)

View source »

Sets the Description of an item.

Parameters

Returns

  • ITEM

SetInitialStock(data)

View source »

Sets the initial dynamic economy stock for this item.

Parameters

  • data int

    Initial Stock Count

Returns

  • ITEM

SetModel(model, skin, autoStore)

View source »

Sets the model of the item. If model is true, the model and skin will be pulled from the store model. If autostore is true, model and skin will be pushed to the store model.

Parameters

  • model string or true

    Model path.

  • skin int

    Skin index.

  • autoStore bool optional

    Should this call also automatically set the store models.

Returns

  • ITEM

SetName(name, plural)

View source »

Sets the name of an item. If plural is undefined, defaults to "s" If plural is true, it's set to ""

Parameters

  • plural string or false default: <name>s

    Optional plural to set.

Returns

  • ITEM

SetPlural(name)

View source »

Sets the item's plural. If nil/false, item's name + s is used. If true, item's name is used. Otherwise passed name is used.

Parameters

  • name string or true optional

Returns

  • ITEM

SetPrice(data)

View source »

Alias of ITEM:SetCost

Parameters

  • data int

    Cost.

Returns

  • ITEM

See Also

SetSize(data)

View source »

Sets the inventory size of this item.

Parameters

  • data int

    Size

Returns

  • ITEM

SetSkin(skin, autoStore)

View source »

Sets the skin of the item. If skin is true, it is pulled from the store skin.

Parameters

  • skin int or true

    skin

  • autoStore bool optional

    If skin should be pushed to store skin.

SetStore(val)

View source »

Set if the item is in store, and its batch amount. If boolean, store is directly set. If 0, store is set to false. Otherwise store is set true and the value

Parameters

  • val bool or int

    Store Setting / Batch Amount

Returns

  • ITEM

SetStoreModel(model, skin)

View source »

Sets the store model of the item. If model is true, the model and skin will be pulled from the regular model.

Parameters

  • model string or true

    Model path.

  • skin int

    Skin index.

Returns

  • ITEM

SetStoreSkin(skin, autoStore)

View source »

Sets the store skin of the item. If skin is true, it is pulled from the item skin.

Parameters

  • skin int or true

    skin

  • autoStore bool optional

    If skin should be pushed to item skin.

SetSupporter(data)

View source »

Sets if the item is for supporters.

Parameters

  • data bool

    Supporter Required.

Returns

  • ITEM

SetSupporterPlus(data)

View source »

Sets if the item is for supporter plus.

Parameters

  • data bool

    Supporter Required.

Returns

  • ITEM

SetTeam(data)

View source »

Sets the team of an item.

Parameters

  • data int

    Team Index

Returns

  • ITEM

Untradable()

View source »

Marks an item as untradable. This disables dropping and giving, but can be overwritten later.

Returns

  • ITEM

Fields

__index

View source »

The lookup index for the item metatable.

category

View source »

Inventory / Market Category

cost

View source »

Item Cost

  • cost int

    The cost of the item as bought in the market. Also used for inventory valuations and refund sales.

description

View source »

Description of the item.

model

View source »

Model Path

  • model string

    Path of the model used in the F1 menu / dropped states.

name

View source »

Item Name.

  • name string

    The localised name, as shown in the F1 menu.

size

View source »

Item Size

  • size number

    The inventory space used per item.

skin

View source »

Skin used in the F1 menu.

  • skin int

store

View source »

Market Availability

  • store bool