Skip to content
On this page

Athena.systems.inventory.factory

Functions

fromBaseToStored

Usage

Athena.systems.inventory.factory.fromBaseToStored<CustomData>(baseItem, quantity): any

Converts a base item into a stored item for reference.

Type parameters

NameType
CustomData{}

Parameters

NameType
baseItemBaseItem<DefaultItemBehavior, CustomData>
quantitynumber

Returns

any

Defined in

server/systems/inventory/factory.ts:391


fromBaseToStoredAsync

Usage

Athena.systems.inventory.factory.fromBaseToStoredAsync<CustomData>(baseItem, quantity): Promise<player<CustomData>>

Converts a base item to a stored item asynchronously.

Type parameters

NameType
CustomData{}

Parameters

NameType
baseItemBaseItem<DefaultItemBehavior, CustomData>
quantitynumber

Returns

Promise<player<CustomData>>

Defined in

server/systems/inventory/factory.ts:243


fromStoredItem

Usage

Athena.systems.inventory.factory.fromStoredItem<CustomData, CustomBehavior>(item): player<CustomBehavior & player, CustomData> | undefined

Converts an item from a player inventory, or toolbar to a full item set.

Also performs weight calculations.

Use when usage is not at server-start.

Type parameters

NameType
CustomData{}
CustomBehaviorDefaultItemBehavior

Parameters

NameType
itemStoredItem<CustomData>

Returns

player<CustomBehavior & player, CustomData> | undefined

Defined in

server/systems/inventory/factory.ts:327


fromStoredItemAsync

Usage

Athena.systems.inventory.factory.fromStoredItemAsync<CustomData, CustomBehavior>(item): Promise<player<CustomBehavior & player, CustomData> | undefined>

Converts an item from a player inventory, equipment, or toolbar to a full item set.

Also performs weight calculations.

Type parameters

NameType
CustomData{}
CustomBehavior{}

Parameters

NameType
itemStoredItem<CustomData>

Returns

Promise<player<CustomBehavior & player, CustomData> | undefined>

Defined in

server/systems/inventory/factory.ts:175


getBaseItem

Usage

Athena.systems.inventory.factory.getBaseItem<CustomData, CustomBehavior>(dbName, version?): player<player & CustomBehavior, CustomData>

Get a base item based on dbName, and version if supplied.

Does not wait for database of items to load first.

Use when usage is not at server-start.

Type parameters

NameType
CustomData{}
CustomBehavior{}

Parameters

NameTypeDefault value
dbNamestringundefined
version?numberundefined

Returns

player<player & CustomBehavior, CustomData>

Defined in

server/systems/inventory/factory.ts:284


getBaseItemAsync

Usage

Athena.systems.inventory.factory.getBaseItemAsync<CustomData, CustomBehavior>(dbName, version?): Promise<player<player & CustomBehavior, CustomData>>

Get a base item based on dbName, and version if supplied.

Type parameters

NameType
CustomData{}
CustomBehavior{}

Parameters

NameTypeDefault value
dbNamestringundefined
version?numberundefined

Returns

Promise<player<player & CustomBehavior, CustomData>>

Defined in

server/systems/inventory/factory.ts:51


getBaseItemByFuzzySearch

Usage

Athena.systems.inventory.factory.getBaseItemByFuzzySearch<CustomData>(partialName): player<player, CustomData> | undefined

Searches for a base item based on a fuzzy search. Specify either 'myitem', 'My_Item', or 'My Item'.

Will try to find a match in the following order:

  • Exact dbname
  • Exact name
  • Partial name
  • Partial dbname

Export

Type parameters

NameType
CustomData{}

Parameters

NameType
partialNamestring

Returns

player<player, CustomData> | undefined

Defined in

server/systems/inventory/factory.ts:463


getBaseItems

Usage

Athena.systems.inventory.factory.getBaseItems(): player[]

Does not wait for items to load, returns what base items are in the array.

Use this only during runtime; and not during startup.

Export

Returns

player[]

Defined in

server/systems/inventory/factory.ts:440


getBaseItemsAsync

Usage

Athena.systems.inventory.factory.getBaseItemsAsync(): Promise<player[]>

Waits for the database items to finish loading before returning data.

Export

Returns

Promise<player[]>

Defined in

server/systems/inventory/factory.ts:423


isDoneLoadingAsync

Usage

Athena.systems.inventory.factory.isDoneLoadingAsync(): Promise<void>

Wait until the isDoneLoading variable is set to true before continuing.

Returns

Promise<void>

Defined in

server/systems/inventory/factory.ts:29


override

Usage

Athena.systems.inventory.factory.override(functionName, callback): any

Used to override inventory item factory functionality

Parameters

NameType
functionName"getBaseItemAsync"
callback<CustomData, CustomBehavior>(dbName: string, version?: number) => Promise<player<player & CustomBehavior, CustomData>>

Returns

any

Defined in

server/systems/inventory/factory.ts:515

Usage

Athena.systems.inventory.factory.override(functionName, callback): any

Used to override inventory item factory functionality

Parameters

NameType
functionName"upsertAsync"
callback(baseItem: BaseItem) => any

Returns

any

Defined in

server/systems/inventory/factory.ts:516

Usage

Athena.systems.inventory.factory.override(functionName, callback): any

Used to override inventory item factory functionality

Parameters

NameType
functionName"fromStoredItemAsync"
callback<CustomData, CustomBehavior>(item: StoredItem<CustomData>) => Promise<player<CustomBehavior & player, CustomData> | undefined>

Returns

any

Defined in

server/systems/inventory/factory.ts:517

Usage

Athena.systems.inventory.factory.override(functionName, callback): any

Used to override inventory item factory functionality

Parameters

NameType
functionName"fromBaseToStoredAsync"
callback<CustomData>(baseItem: BaseItem<DefaultItemBehavior, CustomData>, quantity: number) => Promise<player<CustomData>>

Returns

any

Defined in

server/systems/inventory/factory.ts:518

Usage

Athena.systems.inventory.factory.override(functionName, callback): any

Used to override inventory item factory functionality

Parameters

NameType
functionName"getBaseItem"
callback<CustomData, CustomBehavior>(dbName: string, version?: number) => player<player & CustomBehavior, CustomData>

Returns

any

Defined in

server/systems/inventory/factory.ts:519

Usage

Athena.systems.inventory.factory.override(functionName, callback): any

Used to override inventory item factory functionality

Parameters

NameType
functionName"fromStoredItem"
callback<CustomData, CustomBehavior>(item: StoredItem<CustomData>) => player<CustomBehavior & player, CustomData> | undefined

Returns

any

Defined in

server/systems/inventory/factory.ts:520

Usage

Athena.systems.inventory.factory.override(functionName, callback): any

Used to override inventory item factory functionality

Parameters

NameType
functionName"toStoredItem"
callback<CustomData>(item: Item<DefaultItemBehavior, CustomData>) => player<CustomData>

Returns

any

Defined in

server/systems/inventory/factory.ts:521

Usage

Athena.systems.inventory.factory.override(functionName, callback): any

Used to override inventory item factory functionality

Parameters

NameType
functionName"fromBaseToStored"
callback<CustomData>(baseItem: BaseItem<DefaultItemBehavior, CustomData>, quantity: number) => any

Returns

any

Defined in

server/systems/inventory/factory.ts:522

Usage

Athena.systems.inventory.factory.override(functionName, callback): any

Used to override inventory item factory functionality

Parameters

NameType
functionName"getBaseItems"
callback() => player[]

Returns

any

Defined in

server/systems/inventory/factory.ts:523

Usage

Athena.systems.inventory.factory.override(functionName, callback): any

Used to override inventory item factory functionality

Parameters

NameType
functionName"getBaseItemsAsync"
callback() => Promise<player[]>

Returns

any

Defined in

server/systems/inventory/factory.ts:524

Usage

Athena.systems.inventory.factory.override(functionName, callback): any

Used to override inventory item factory functionality

Parameters

NameType
functionName"getBaseItemByFuzzySearch"
callback<CustomData>(partialName: string) => player<player, CustomData> | undefined

Returns

any

Defined in

server/systems/inventory/factory.ts:525


toStoredItem

Usage

Athena.systems.inventory.factory.toStoredItem<CustomData>(item): player<CustomData>

Converts a full item, into a storeable version of the item.

Only certain parts of the item will be stored.

Use when usage is not at server-start.

Type parameters

NameType
CustomData{}

Parameters

NameType
itemItem<DefaultItemBehavior, CustomData>

Returns

player<CustomData>

Defined in

server/systems/inventory/factory.ts:359


toStoredItemAsync

Usage

Athena.systems.inventory.factory.toStoredItemAsync<CustomData>(item): Promise<player<CustomData>>

Converts a full item, into a storeable version of the item.

Only certain parts of the item will be stored.

Type parameters

NameType
CustomData{}

Parameters

NameType
itemItem<DefaultItemBehavior, CustomData>

Returns

Promise<player<CustomData>>

Defined in

server/systems/inventory/factory.ts:207


upsertAsync

Usage

Athena.systems.inventory.factory.upsertAsync(baseItem): any

Updates or inserts a new database item into the database.

If a verison is specified and it does not find a matching version it will add a new item.

If a version is not specified; it will find a non-versioned item to replace.

Example

ts
Athena.systems.inventory.factory.upsertAsync({
    dbName: 'burger',
    data: { health: 5 },
    icon: 'burger',
    name: 'Burger',
    maxStack: 8,
    weight: 25,
    behavior: {
        canDrop: true,
        canStack: true,
        canTrade: true,
        destroyOnDrop: false,
        isToolbar: true
    },
    consumableEventToCall: 'edible',
    customEventsToCall: [
         {
             name: 'Desconstruct',
             eventToCall: 'deconstruct-item-ingredients'
         }
   ]
});

Parameters

NameType
baseItemBaseItem

Returns

any

Defined in

server/systems/inventory/factory.ts:119

Created by Stuyk | Est. 2020