Pockets & Categories
Pockets & Categories
A pocket accepts one weapon of a matching category and shows it lying in that compartment of the bag. The interface lays itself out from Config.Slots, so adding or removing a pocket is a config edit plus one locale line.
The default layout
| Accepts | Stack | |
|---|---|---|
primary_1, primary_2 |
primary |
1 |
smg_1 |
smg, primary |
1 |
sidearm_1, sidearm_2, sidearm_3 |
sidearm |
1 |
melee_1 |
melee |
1 |
ammo_1, ammo_2 |
ammo, attachment |
500 |
ammo_3 |
ammo, throwable |
50 |
Two full-length pockets fill the left half of the bag so long guns lie head to toe; the right half is stacked compartments with small pockets along the bottom.
Defining a pocket
{ id = 'primary_1', accepts = { 'primary' },
ui = { x = 14.0, y = 8.0, w = 16.7, h = 77.0, rotate = -90, scale = 0.92 } },| Field | Meaning |
|---|---|
id |
Internal name, must be unique. Also the locale key: slot_<id>. |
accepts |
Which categories this pocket takes. |
ui.x / ui.y |
Top-left corner of the pocket, as percentages of the bag picture. |
ui.w / ui.h |
Size of the pocket, also in percentages. |
ui.rotate |
Degrees clockwise. Turns the weapon so it lies along the pocket instead of being pasted flat across it. |
ui.scale |
How much of the pocket the weapon fills, 0 to 1. |
stack |
How many units the pocket holds. Omit for 1. |
A weapon is one object and wants stack = 1. Ammunition is counted in rounds and a player may be carrying hundreds, so an ammo pocket takes a whole stack in one drag and shows the number on it.
ui.rotate matters more than it sounds. A rifle picture is wide and a primary pocket is tall — without the rotation the rifle is squeezed into a sliver in the middle and looks stuck on rather than packed away.
The default coordinates line up with the bag picture in ui/src/bag.jpg. Swap that picture for your own and those are the numbers to drag around. Order matters too: the first pocket in the list is the first one highlighted when a player starts dragging.
Categories
Weapons are sorted by name, lowercase, with or without the WEAPON_ prefix. You never maintain a full weapon list — only the exceptions.
Config.CategoryRules = {
{ category = 'primary', contains = { 'rifle', 'carbine', 'shotgun', 'sniper', 'mg', 'rpg', 'launcher', 'railgun', 'minigun' } },
{ category = 'smg', contains = { 'smg', 'mp5', 'uzi', 'tec', 'gusenberg', 'machinepistol' } },
-- sidearm, melee, throwable, ammo, attachment…
}Rules are checked top to bottom and the first match wins. The shipped categories are primary, smg, sidearm, melee, throwable, ammo and attachment.
Overrides
Exceptions win over the rules, and are the right place for addon weapons whose names the matching gets wrong:
Config.CategoryOverrides = {
['weapon_musket'] = 'primary',
['weapon_marksmanrifle'] = 'primary',
['weapon_machinepistol'] = 'smg',
['weapon_pistol50'] = 'sidearm',
}The fallback
Config.DefaultCategory = 'sidearm' -- false = refuse uncategorised weaponsThis only ever applies to items whose name begins with weapon_. Food, phones and the rest of the inventory are never offered to the bag no matter what it is set to. Setting it to false is the stricter choice if you run addon weapons you have not sorted yet.
Ammunition is recognised on its own, by names beginning or ending with ammo- / ammo_, so it lands in an ammo pocket without needing a rule.
Capacity
Config.Capacity = {
MaxWeight = 30.0, -- kilograms
MaxItems = 10,
}Item weights are read from your own inventory, so MaxWeight lines up with the numbers players already see when they open their inventory. MaxItems is a hard cap regardless of weight — there is no point setting it above the number of pockets, because the pockets run out first.
Adding a pocket needs a slot_<id> entry in every locale file, and a new category needs a cat_<category> entry to match.