ships.Function.parseSlotName - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki
@elite-dangerous-almanac/core / ships / parseSlotName
parseSlotName(
slot):ParsedSlot|null
Defined in: src/ships/slots.ts:593
Classify a journal slot name — the Slot field of a SLEF/journal module — into a
ParsedSlot.
string
The journal slot name, e.g. "FrameShiftDrive", "MediumHardpoint2",
"Slot03_Size5", "Military01", "LargeMiningHardpoint1". Matched
case-insensitively — see the remarks.
ParsedSlot | null
The classification, or null if the name is not a recognised slot. size
is null for names that do not encode a size (a bare Military01).
Every restricted mount has a journal name of its own, so the restriction is read
off the name and needs no hull layout. The size still may: Cargo01 says only
that the mount takes cargo, and getShipSlots carries how big it is.
Casing is not significant. Frontier writes FrameShiftDrive, but a SLEF
producer may lower-case every slot key as the specification's own example does —
Inara writes powerplant and largemininghardpoint1 — and both name the same
mount. The returned core and restriction values keep this library's own
camelCase spelling whatever the input looked like.
A _SizeN suffix is what the name says, not what the mount is. On some hulls
the game's own key disagrees with the mount it names — the Keelback's
Slot03_Size3 is a size-4 mount, the Asp Scout's Slot01_Size4 a size-5 one, and
five of the Type-7 Transporter's ten are off. To size a mount, find it in the hull's
layout (enumerateSlots) rather than trusting the number returned here.
If slot is present and not a string. A nullish slot is a miss,
answered the way an unrecognised key is.
import { parseSlotName } from '@elite-dangerous-almanac/core/ships/slots';
parseSlotName('Slot03_Size5'); // -> { kind: 'optional', size: 5 }
parseSlotName('HugeHardpoint1'); // -> { kind: 'hardpoint', size: 4 }
parseSlotName('LargeMiningHardpoint1');
// -> { kind: 'hardpoint', size: 3, restriction: 'mining' }
parseSlotName('Radar'); // -> { kind: 'core', size: null, core: 'sensors' }
parseSlotName('powerplant'); // -> { kind: 'core', size: null, core: 'powerPlant' }