Skip to content

Integration API ​

np_security is the source of truth for venue access lists, bans, capacity, door logs, and wristbands. Ticket state stays in the ticket resource. Admission-provider registrations are in memory and are owned by the registering resource; attach again after the host restarts.

Admission provider ​

Register from the server side of an np_addon attachment:

lua
exports.np_security:registerAdmissionProvider('ent_tickets', {
  label = 'Ticket', icon = 'ticket',
  check = function(src, venueId, ctx)
    -- venueId is the provider's own venue ID; ctx includes siteId, citizenId, night, and bucket.
    return { ok = true, label = 'VIP', status = 'valid · first entry', tier = 'vip', plusOnes = 1, ref = ticketId }
  end,
  consume = function(src, venueId, ref, by)
    -- Mark the provider's record consumed exactly once and return true only on success.
    return true
  end,
  -- Optional compensation if a later provider-specific step fails.
  release = function(src, venueId, ref, by) end,
})

check may return nil when the guest has no entitlement. ok = false returns a visible unavailable/invalid row; ok = true allows the door to preselect the provider and derive the wristband tier from it. The provider's consume(src, venueId, ref, by) callback runs after capacity and ID checks and the local wristband/log writes pass. A failed consume rolls those local writes back. Keep provider callbacks idempotent, local, and fast; checks over the configured time limit are treated as unavailable. release is an optional compensation hook for integrations that can restore an already-consumed entitlement. A provider must make consume atomic or provide safe compensation: if it mutates its own state and then throws or returns failure, np_security cannot know whether to undo that mutation. The current np_entertainment ticket callback has no release operation, so a failure inside its own consume path can leave the ticket consumed while the door denies entry. This cannot be fixed host-side without risking a free admission or undoing another operation.

Current cross-resource contracts:

  • np_entertainment creates its linked venue:<venue_id> security site through the legacy site-link shorthand. np_security resolves that site's ID back to venue_id when calling ticket checks and consumption, and accepts venue_id for its lineup list APIs. Ticket truth remains in ent_tickets.
  • np_housing party invitations and np_casino membership can register providers using the callback API above.
  • Site IDs accept lowercase letters, digits, _, -, and :. site.bucket separates reused interiors. Door points may specify their own door.bucket.

Site and event APIs ​

lua
exports.np_security:registerSite({ id, kind = 'venue', label, bucket, door, capacity, capacityMax, ageLimit })
exports.np_security:getVenue(siteId) -- base config merged with current override
exports.np_security:updateSite(siteId, { capacity, ageLimit }) -- persistent base config
exports.np_security:updateSite(siteId, { capacity, ageLimit }, { untilTs = eventEnd }) -- per-night override
-- Equivalent explicit form:
exports.np_security:setNightOverride(siteId, { capacity, ageLimit }, { untilTs, ref })
exports.np_security:clearNightOverride(siteId, 'np_entertainment', eventId)

local entryId = exports.np_security:addListEntry(venueId, {
  kind = 'guest', night = '2026-10-10', citizenId = citizenId,
  plusOnes = 1, by = 'event lineup', source = 'np_entertainment', ref = eventId,
})
exports.np_security:removeListEntriesBySource(venueId, 'np_entertainment', eventId)

The caller resource is always the stored source. The optional source argument must match the invoking resource; one resource cannot erase another resource's individual entry or event batch. A list entry with night expires at the venue's effective closing time for that date. An explicit untilTs expires at that timestamp. Ending or cancelling an np_entertainment event removes its matching override and event-scoped lineup entries; the security resource also reconciles ended event rows after a restart. Night-scoped entries are active on their date and remain active into the next calendar day only while their explicit validity timestamp is still in the future. Name-only entries require the presented, verified ID name to match; citizen-ID entries match only that ID, so use citizenId for stable admission identity.

Door exports ​

  • checkAdmission(src, siteId, actor?) returns identity, list and provider results. External callers must be a trusted site integration or provide an authorized door-staff actor.
  • admit(src, siteId, actor, providerName?, plusOneOf?) checks authorization, bucket, ID, capacity, and bans before granting the wristband. Provider tickets and an existing plus-one token are mutually exclusive.
  • getVenueCount(siteId) / changeVenueCount(siteId, delta, actor) expose the bucket or clicker counter.
  • findSite(coords, bucket) finds the nearest matching venue door in that routing bucket.

Wristbands are registered as an np_inventory item when that resource is available. Their metadata includes the security site, night, tier, expiry, and provider name.

Cash in transit ​

Define route stops server-side in Config.Security.CitRoutes. A stop may be a checkpoint or an inventory transfer:

lua
Config.Security.CitRoutes = {
  city = { stops = {
    { label = 'Load depot bags', coords = { x = 1, y = 2, z = 3 }, action = 'load',
      sourceStash = 'bank_cit_depot', item = 'cit_bag', count = 2 },
    { label = 'Deliver to branch', coords = { x = 4, y = 5, z = 6 }, action = 'unload',
      destinationStash = 'bank_cit_branch', item = 'cit_bag', count = 2 },
  } },
}

load removes the configured item/count from the source stash into the run's private inventory manifest; unload moves it from that manifest to the destination stash. The crew must be at each stop and in its configured transport vehicle. The route cannot complete while items remain in the manifest. Route source and destination stashes must be registered with np_inventory and populated by the owning resource. Active run manifests are re-registered when np_inventory restarts. If the server crashes during a transfer, the durable stop claim remains processing and the run fails closed at that stop. Reconcile the source, destination, and manifest inventories before an operator clears the claim; replaying it without reconciliation could duplicate or lose cargo.

Housing and banking alarm routing ​

Housing emits np_housing:alarm(propertyId, kind, coords). Banking emits np_banking:securityAlarm(payload) when its configured robbery alarm is raised. Map external IDs to security sites so active alarm contracts select the security channel:

lua
Config.Security.AlarmSites = {
  np_housing = { ['house_102'] = 'house_102_security' },
  np_banking = { ['atm:central_01'] = 'central_bank_security' },
}

Banking alarm payloads may set securitySite directly. Existing security site IDs are also accepted as external IDs. Unmapped alarms can still be recorded when the source supplies coordinates, but cannot select a site contract.

np_jobs dependency ​

The security feature pack follows the runnable np_jobs §12 host API and compatibility rules. It declares the np_jobs addon relationship, registers each security.* capability, and checks every guarded action through hasFeature(src, id, { place = siteId }). It has no hardcoded job-name fallback and fails closed when the host is unavailable.