Client exports

All primary exports are client-side: call them from a client script, never from a server script.

show(data)

Creates a prompt. If the calling resource already owns a prompt with that id, it is replaced with the new data instead of being duplicated.

client.lua

local handle = exports.jex_interactions:show({
    id       = 'vehicle_storage',
    key      = 'E',
    label    = 'Store vehicle',
    hint     = 'Backspace to cancel',
    state    = 'ok',
    priority = 10,
    duration = 2500,
})

It returns the prompt's full string handle, or nil when the supplied data is invalid.

FieldTypeRequiredWhat it is
labelstring · numberYesMain prompt text. text and title are accepted as aliases.
idstring · numberNoStable identifier for later updates and removal. If omitted, a unique one is assigned.
keystring · numberNoKey shown by the HUD. Defaults to Config.DefaultKey. It is a label only: it does not register or listen for the control.
hintstring · numberNoOptional secondary text.
statestringNoVisual state: ok, warn or bad. Invalid or omitted values use ok.
prioritynumberNoDisplay priority: higher values appear first. Defaults to 0.
durationnumberNoLifetime in milliseconds. A positive value removes the prompt automatically. Omit it, or use 0, for a persistent prompt.

Input limits are 48 bytes for id, 8 for key and 96 for label and hint. Empty values are not valid where text is required.

Keep the returned handle when you create a prompt without an explicit id:

client.lua

local handle = exports.jex_interactions:show({
    key      = 'G',
    label    = 'Trunk opened',
    duration = 2000,
})

if handle then
    -- The same handle can be passed to has, update or hide.
end

update(ref, patch)

Updates selected fields of an existing prompt. It returns true when the prompt was found and updated, otherwise false. It never creates a missing prompt.

client.lua

local updated = exports.jex_interactions:update('vehicle_storage', {
    label    = 'Vehicle cannot be stored here',
    state    = 'bad',
    priority = 20,
})

Fields not included in patch keep their existing values. The aliases text and title also update the main label. Use hint = false to remove the current hint:

client.lua

exports.jex_interactions:update('vehicle_storage', { hint = false })

If a timed prompt is updated without supplying duration, its existing expiry time is preserved. Set duration = 0 to make it persistent, or supply a new positive duration to start a new lifetime.

hide(ref)

Removes one prompt owned by the calling resource. It returns true if the prompt existed.

client.lua

exports.jex_interactions:hide('vehicle_storage')

hideAll()

Removes every prompt owned by the calling resource and returns how many were removed. Prompts created by other resources are not affected.

client.lua

local removed = exports.jex_interactions:hideAll()

has(ref)

Returns whether the referenced prompt is currently registered.

client.lua

if exports.jex_interactions:has('vehicle_storage') then
    exports.jex_interactions:update('vehicle_storage', { state = 'warn' })
end

active()

Returns an array of the currently visible full handles, in display order. It contains at most Config.MaxVisible entries.

client.lua

local handles = exports.jex_interactions:active()

for index, handle in ipairs(handles) do
    print(index, handle)
end

Prompt references and ownership

update, hide and has accept either form:

  • The short ID assigned by the calling resource, such as vehicle_storage.
  • The full handle returned by show, such as my_garage:vehicle_storage.

Prompt IDs are scoped to the resource that creates them, so different resources may safely use the same short ID. For normal use, a resource should manage only its own prompts and prefer short IDs.