NUI contract (Lua ⇄ web) ​
The message contract between the Lua client, the web UI and the server. The full source of truth is
docs/ARCHITECTURE.md in the resource
(§3 core objects, §4 NUI protocol, §5 server RPC, §11 changes made during implementation); this page summarises it and
adds the decisions the web made where the contract leaves room (web/README.md). You only need it to change the web
UI or write a different front end. Resources that use the exports never touch it.
The rule: ped natives live in Lua, the parlour state lives in the web. The web owns the selection, the basket and the preview set, and tells Lua what to show on the ped. The server is authoritative for money, the catalogue, restrictions, healing, removal cooldowns, expiry and moderation.
Lua → web: SendNUIMessage({ action, data }) ​
Messages sent before the web posted ready are queued (up to 128) and flushed after boot.
| action | data | meaning |
|---|---|---|
boot |
{ locale, strings, material, scale?, currency, config } |
Once after ready (again after a web reload). config = { zones, styles, removal: { sessions, price, cooldownMinutes, priceByZone }, cover: { discount, crewDiscount }, temporary: { days }, accounts } |
parlour:open |
{ mode, shop: { id, label, sub?, tabs }, catalogue, ink, money: { cash, bank }, gender, canSubmit, kit? } |
Show the parlour. mode is shop, prison or temp; kit = { item, label, count } in kit modes |
parlour:update |
partial { ink?, money?, catalogue?, kit? } |
After a push or a catalogue reload |
admin:open |
{ submissions, designs, audit } |
Review panel |
admin:update |
partial of the same | After a review or toggle |
notify |
{ type, title, message, icon?, tint?, duration? } |
Toast. Shown without taking focus, also while no UI is open |
hide |
{ ui: boolean } |
Hide / show the parlour or panel; toasts stay |
close |
{} |
Close everything |
Design (wire) ​
{ name, label, zone, collection, hash: string | null /* current gender; null = hidden */, price, style, kind,
glyph?, image?, isNew?, mirror?, crew?: { label }, locked?: string /* localised reason */, days?: number,
variants: { id: 'bw' | 'color' | 'faded', price: number, hash?, collection? }[] /* bw first */ }
The color variant also carries its hash and collection so the client can preview it. In prison and kit modes all
prices are 0.
Web → Lua: fetch('https://np_tattoos/<name>', { method: 'POST', body }) ​
Every callback answers JSON exactly once: { ok: true, … } or { ok: false, code?, error }. error is a display
string. Server errors pass through unchanged; Lua turns its own codes (busy, not_open, timeout, …) into text and
keeps the raw code in code.
| name | body | Lua does |
|---|---|---|
ready |
{} |
Sends boot, flushes the queue (or re-sends the open screen after a web reload) |
close |
{} |
Restores clothing and ink, camera off, focus off, shop:close |
preview |
{ items: { name, variant }[], hide?: number[] } |
Re-applies owned ink without the hide ids, plus the preview items |
camera |
{ zone } | { orbit } | { heading } | { zoom } |
Moves the camera (and undresses for a zone). Answers { ok, heading } |
undress |
{ on } |
Undress the shown zone (on by default) |
pose |
{ on } |
Arms-out pose |
checkout |
{ items: { name, variant, side? }[], account } |
shop:checkout. Answers { ok, ink, money, kit? } |
removal |
{ id, account } |
shop:removal (one laser session). Answers { ok, ink, money } |
cover |
{ id, name, variant, account } |
shop:cover. Answers { ok, ink, money } |
submit |
{ label, zone, collection, hashMale, hashFemale, price, style, image?, crew? } |
shop:submit. Answers { ok, submission } |
admin:review |
{ id, approve, reason? } |
admin:review, then admin:update |
admin:toggle |
{ name, enabled } |
admin:toggle, then admin:update |
Server RPC (client ⇄ server) ​
The client calls NpTat.rpc(name, payload): a request id over np_tattoos:rpc, answered on the same event, with a
10 s timeout. Each RPC is registered with a payload schema, a rate limit, optionally a permission (perm: an
np_admin node, or a function returning one, checked through npAdmin.can on every call), and whether a character
must be loaded. The check order is: global token bucket (Config.RateLimit) → payload sanity (depth, keys, sizes) →
loaded character → permission node → per-RPC rate → one call in flight per player and name → schema (unknown keys dropped).
| RPC | Payload | Purpose |
|---|---|---|
ink:mine |
{ model? } |
{ ink, gender }. A freemode model name or hash decides the gender |
shop:open |
{ mode, shopId? } |
Distance / jail / kit check, opens the session, answers the parlour payload flat |
shop:close |
{} |
Closes the session |
shop:checkout |
{ items (1–20), account } |
Purchase |
shop:removal |
{ id, account } |
One laser session |
shop:cover |
{ id, name, variant, account } |
Cover-up |
shop:submit |
submission fields | Custom design submission |
ink:swam |
{ ids } |
Healing pieces that got wet |
admin:list / admin:review / admin:toggle |
Review panel (np_tattoos.admin, no character needed) |
|
marks:nearby |
{ target } |
/marks lookup |
shop:checkout, shop:removal, shop:cover and shop:submit need an open session, which is re-checked on every
call: the shop distance (radius + 5 m), or the jail state in prison mode. Sessions opened by an export skip those
checks. A session closes on shop:close, a disconnect, a character switch, or when a check fails.
Web implementation notes ​
- Preview: the web sends
previewwhenever the shown set changes (deduplicated, at most once per frame): the basket items plus the hovered (else selected) design with its variant; Both sends the design and its mirror. Cover-up sends the chosen design plushide = [oldId]; removal sendshide = [id]only while "Preview without" is on. - Mirror sides: for Left / Right the checkout item
nameis already the design on that side, andsideis only sent for designs with amirror. Both sends the selected design withside = 'both'. - Success toasts come from the server; the web only toasts callback errors.
- Reject reason is optional (
reasonis omitted when empty). Audit action ids map toui.audit_<id>strings. - Submit tab shows only when
shop.tabscontainssubmitandcanSubmitis true. - Body map: torso and head pieces whose
nameorhashcontains back, spine, nape or calf are drawn on the back figure. - Drag orbits are summed per frame; the wheel sends absolute zoom −1 … 1 in 0.1 steps.