NUI contract ​
The contract between the Lua client, the web UI (web/) and the server RPCs behind it. The wire types are mirrored in
web/src/lib/types.ts and web/src/screens/<module>/types.ts and checked by web/scripts/check-contract.mjs. You only
need this page to change the UI or write your own front end; resources that work with screening use the
exports.
The NUI is server-authoritative: it only sends intents. Positions, permissions, readings, items and money come from the
server. The client never sends an outcome. The gate and the findings give the NUI zone values, classes and sides, and
names only after a reveal (Detection.view(item, revealed)).
Messages ​
Lua → NUI: SendNUIMessage({ action, data }), queued by NpScanner.sendNui until the NUI calls ui.ready.
| Action | Data |
|---|---|
init |
{ locale, strings, player = { identifier, name, job, grade, onDuty, staff = { admin, place, configure, logs, override } }, config = { keys, zones, sides, classes, scannerTypes, inventory, framework, imagePath, kgPerMass }, venues, sync, modules }. Every string of the Lua locale files, so Lua stays the single source |
open |
{ screen, data }: opens a focus screen (the client takes NUI focus) |
close |
{ screen? } |
update |
{ screen, data }: a partial live patch (a shallow merge) for an open screen or a visible HUD layer. The wand patches at 10 Hz |
hud |
{ layer, data? }: a non-focus HUD layer; no data hides it |
hud:notify |
{ type, title, message, icon, tint, duration, app }: a toast while np_hud is not running |
theme |
{ brand?, strength, material }: np_admin's server theme, sent by bridge/np_admin.lua at start, on every change and again on ui.ready |
NUI → Lua: one callback, https://np_metal-scanner/rpc, with { method, params }. It answers { ok: true, data } or
{ ok: false, error }. Methods registered with NpScanner.clientRpc.register (ui.ready, ui.close, placement.preview,
placement.transform, wand.local) answer on the client; everything else is forwarded to the server RPC dispatcher.
Every error code is a locale key error.<code> in English and German.
Screens and HUD layers ​
web/src/screens/<module>, registered with defineScreen({ id, component, kind?, escClose?, dim?, order? }):
| id | Kind | Opened by | Data |
|---|---|---|---|
operator |
focus (no dim) | The gate panel with the cursor | OperatorData |
gate-operator |
HUD | NpScanner.hud('gate-operator') on an alarm |
OperatorData |
gate-tags |
HUD | The floating labels above gates | { tags: [{ id, x, y, gate, state, zones }] } |
wand |
HUD | A wand run | WandData |
wand-consent |
HUD | The target's question | ConsentData |
findings |
focus | findings.open, a wand finish |
FindingsData |
tray |
focus | tray.open |
TrayData |
xray |
focus | xray.open |
XrayData |
console |
focus | console.open |
ConsoleData |
placement |
focus | /scannerplace |
PlacementData |
case |
focus | cases.show |
CaseData |
ground |
HUD | The ground detector | GroundData |
ground-journal |
focus | J with the detector |
{ finds, total, goal } |
ground-buyer |
focus | The buyer NPC | { items, buyer } |
prompt, progress |
HUD | Fallbacks while np_hud is not running | { id, icon?, tint?, keys } / { id, label, icon?, tint?, duration, elapsed?, cancelKey? } |
Esc on a focused screen sends ui.close unless the screen opted out. Screens starting with _ are examples.
RPC methods ​
Server RPCs are registered with NpScanner.RPC.register('<module>.<name>', fn, opts). Every one has a schema; the options
add a cooldown, guards (staff, job, onduty, operate for the venue of params.scanner or params.venue, alive)
and a token cost. The order is: method → rate limit → ready → sane params → character → admin → staff → job → duty →
alive → in flight → schema → operate → cooldown → handler. np_metal-scanner.override passes job, duty and operate.
| Module | Methods |
|---|---|
gate |
gate.pass, gate.decide { session, verb }, gate.operator |
wand |
wand.start, wand.consent { session, verb }, wand.sweep, wand.patdown { session, zone }, wand.turn, wand.sensitivity { session, value }, wand.finish |
findings |
findings.open, findings.patDown { session, venue, zone }, findings.apply { session, venue, keys, verb }, findings.requestId, findings.fullSearch |
lockers |
lockers.mine, lockers.claim { venue }, lockers.leave { venue }, lockers.lostFound { venue } |
cases |
cases.list, cases.get, cases.handOff, cases.close, cases.release, cases.evidence, cases.show |
tray |
tray.open { scanner }, tray.move { tray, key, into }, tray.declare { tray, key, decision }, tray.submit, tray.leave |
xray |
xray.open, xray.list, xray.clear { venue, bag }, xray.search { venue, bag }, xray.scan { scanner, slot } |
console |
console.open, console.close, console.stats, console.rules, console.export, console.calibrateStart, console.calibrateFinish |
shifts |
shifts.start { scanner }, shifts.stop, shifts.current, shifts.list |
watchlist |
watchlist.list, watchlist.add, watchlist.remove |
placement |
placement.list, placement.save { scanner }, placement.delete { id }, placement.venue { venue }, placement.test { scanner }; client placement.preview, placement.transform |
venues |
venues.list (staff), venues.mine |
ground |
ground.equip, ground.stop, ground.scan { coords }, ground.begin, ground.tap { token, index }, ground.finish { token }, ground.journal, ground.saleList { buyer }, ground.sell { buyer, slot }, ground.shot |
phone |
phone.init, phone.shift, phone.shiftStart, phone.shiftStop, phone.cases, phone.case, phone.handOff, phone.banCase, phone.watchlist, phone.watchlistAdd, phone.watchlistRemove, phone.stats, phone.permits, phone.venues, phone.lockers, phone.claim, phone.cards |
RPC names and migration ids start with the module name (checked by tests/test_seams.lua).
Types ​
The main shapes (full definitions in web/src/screens/<module>/types.ts):
type Side = 'L' | 'R' | 'C' // zones: 1 head … 7 ankles, indexes are 1-based
type GateVerb = 'wave' | 'secondary' | 'again' | 'hold'
interface OperatorData { session: string; scanner: string; gate: string; venue: string; venueId: string
kind: 'gate' | 'random'; state: 'idle' | 'clear' | 'alarm' | 'offline'; zones: number[]; alarmZones: number[]
objects: number; side?: Side; class?: string; zone?: number; pass: number; time: number
held?: boolean; hold?: boolean; tamper?: boolean; keys?: Partial<Record<GateVerb | 'panel', string>> }
interface WandData { session: string; target: number; targetName: string; operator: number
consent: 'pending' | 'comply' | 'refuse'; coverage: { front: number[]; back: number[] }; face: 'front' | 'back'
signal: number; zones: number[]; battery: number; sensitivity: 'low' | 'med' | 'high'
zone?: number; lateral?: Side; class?: string; massKg?: number; tooFast?: boolean }
interface Finding { key: string; zone: number; side: Side; class: string; source: 'loadout' | 'inventory' | 'body' | 'external'
revealed: boolean; label?: string; name?: string; count?: number; serial?: string; ammo?: number // names only when revealed
group: 'weapons' | 'suspicious' | 'everyday'; belowThreshold: boolean; decision?: 'return' | 'locker' | 'seize' | 'keep'
canReturn: boolean; canTransfer: boolean; permit?: boolean }
interface FindingsData { session: string; venue: string; venueLabel: string; scannerLabel?: string; created: number
subject: { name?: string; idShown: boolean }; items: Finding[]; coverage: { front: number[]; back: number[] }
rules: { weapons: 'none' | 'permit' | 'allowed'; lockers: boolean }; canSearch: boolean; foldEveryday: boolean }
interface TrayData { id: string; scanner: string; gate: string; venue: string; venueLabel: string
rules: { weapons: string; bannedClasses: string[]; lockers: boolean; lockerFee: number }; state: string
items: TrayItem[]; tray: TrayItem[]; capacity: number; permit: boolean; permitAccepted: boolean; ready: boolean; pips: boolean }
// TrayItem { key, name, label, icon?, count, source, slot?, mass, pips: 0..3 | false, category?, class?, weapon }
interface XrayBag { id: string; no: string; venue: string; scanner: string; owner: number; ownerName: string; created: number
shapes: { class: 'organic' | 'mixed' | 'metal' | 'impenetrable'; silhouette: string; x: number; y: number; w: number; h: number
rot: number; flagged: boolean; hint: string }[]
flags: number; status: 'pending' | 'flagged' | 'cleared' | 'searched' | 'returned' }
interface ConsoleData { venue: string; label: string; scanners: { id: string; type: string; label: string; state: string; reason?: string; enabled: boolean }[]
stats: { screened: number; alarms: number; seized: number; declared: number; alarmRate: number; avgWait: number }
rules: { randomSecondary: number; silentAlarm: boolean; chime: boolean }; canConfigure: boolean; log: LogRow[]; bags: XrayBag[]
lockers: { used: number; capacity: number }; evidence: number; shift: boolean; staff: number; latest?: LogRow }
interface CaseData { id: number; ref: string; status: 'open' | 'handed' | 'closed'; created: number; updated: number
venue: { id: string; label: string }; subject: { name?: string }; operator: { name?: string }; summary: string; count: number
hits: { n: number; zone: number; side: Side; tone: 'red' | 'orange' | 'grey'; seized: boolean }[]
items: { name: string; label?: string; count: number; source: string; ammo?: number; serial?: string }[]
mode: 'stash' | 'record'; canPolice?: boolean }
Phone apps ​
web/phone.html → web/dist/phone.html, loaded by np_phone for the two apps. It reads ?app=checkpoint|checkpoint_wallet
and tab=<id> from the iframe. Tabs are definePhoneTab({ id, app, order, icon, label, component, mock }); inside, rpc('<name>')
is np_phone's app RPC (server side registerAppRpc('<appId>', '<name>', fn)), which runs the phone.<name> server RPC. The
shell calls rpc('init') first and gets { locale, strings }. Tabs: Shift, Cases, Watchlist, Stats and Cards, Permits,
Lockers. See Checkpoint & Permits apps.