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.
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.
| Field | Type | Required | What it is |
|---|---|---|---|
label | string · number | Yes | Main prompt text. text and title are accepted as aliases. |
id | string · number | No | Stable identifier for later updates and removal. If omitted, a unique one is assigned. |
key | string · number | No | Key shown by the HUD. Defaults to Config.DefaultKey. It is a label only: it does not register or listen for the control. |
hint | string · number | No | Optional secondary text. |
state | string | No | Visual state: ok, warn or bad. Invalid or omitted values use ok. |
priority | number | No | Display priority: higher values appear first. Defaults to 0. |
duration | number | No | Lifetime 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:
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.
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:
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.
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.
local removed = exports.jex_interactions:hideAll()
has(ref)
Returns whether the referenced prompt is currently registered.
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.
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 asmy_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.