1.2.0 • Published 7 months ago

tf2-backpack v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

node-tf2-backpack

Typed module to parse inventory items from node-tf2 Using this you no longer have to retrieve your own (bots) backpack from the steam API, which has been having issues with increasing ratelimits.

Installation

npm install tf2-backpack
import { BackpackParser } from 'tf2-backpack';
const parser = new BackpackParser(itemsGame);
// or
const tf2backpack = require('tf2-backpack');
const parser = new tf2backpack.BackpackParser(itemsGame);

Docs

Constructor(itemsGame)

  • itemsGame - itemSchema property from node-tf2. See the docs.

Constructs a new BackpackParser.
It is recommended that you save the itemSchema. It is not emitted on every connection, as it is cached. Currently working on figuring out a way to maybe force a refresh, but no promises.

Alternatively, you can also use any vdf parser module and use items_game from items_game.txt (you can find this here or the schema as items_game_url) as input.
Or items-game.json from node-tf2-static-schema
They're the same

parseBackpack

parseBackpack(backpack: NodeTF2Backpack, mapToString = false): Item<string | number>[] {}
  • backpack - backpack property from node-tf2. See the docs.
  • mapToString - set to true to return spells, parts, sheen, killstreaker, killstreakTier and wear as names instead of IDs
  • Returns Item<string | number>[]

parseItem

parseItem(item: BackpackEntry, mapToString = false): Item<string | number> {}
  • item - item from node-tf2's itemAcquired/itemChanged/itemRemoved events. See the docs.
  • mapToString - set to true to return spells, parts, sheen, killstreaker, killstreakTier and wear as names instead of IDs
  • Returns Item<string | number>

Exactly the same as parseBackpack but for a single item for convenience

Other

Since there are no standardized skus for some properties, this module also provides the following exports:

  • spellNames - spell defindex to name
  • sheens
  • killstreakers
  • parts - strange parts

mapHexToPaintName

mapHexToPaintName(primaryColor?: string, secondaryColor?: string): string {}
  • primaryColor - Primary color of the paint can, the paint property from parseBackpack output
  • secondaryColor - Secondary color of the paint can, the paint_other property from parseBackpack output

  • Returns string - Name of the paint

1.2.0

7 months ago

1.1.8

10 months ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

2 years ago

0.0.1

4 years ago