OPX//77
opx_infinitychat

Client

Last updated on

The chat contract on the client — this player's log, completions and the box's on/off switch.

local chat = OPX.Api.Get('chat')

From client code inside opx_infinity. Every function answers { ok = true, value } or { ok = false, error = code }. None yields.

AddMessage

Adds a line to this player's log only.

chat.AddMessage(message)

Parameters

  • message: string | table — or { kind?, author?, text }
    • kind decides the look: say (default), chat, error, warning.

Returns

  • Result true — error chat.invalidMessage
Example
chat.AddMessage({ kind = 'error', author = 'NCPD', text = 'You are wanted.' })

ClearMessages

Empties this player's log.

chat.ClearMessages()

Returns

  • Result true

AddSuggestion

Adds or replaces one completion in the input line.

chat.AddSuggestion(command, help, params)
chat.AddSuggestion({ command, help, parameters })

Parameters

  • command: string — also name in the table form.
  • help?: string
  • params?: table — also parameters in the table form.

Returns

  • Result true — error chat.invalidCommand
Example
chat.AddSuggestion('/opx.mything', 'Does my thing')

RemoveSuggestion

Removes one completion.

chat.RemoveSuggestion(command)

Parameters

  • command: string

Returns

  • Result true

SetEnabled

false closes the box and refuses to open it.

chat.SetEnabled(enabled)

Parameters

  • enabled: boolean

Returns

  • Result — the new state

IsEnabled

chat.IsEnabled()

Returns

  • Result boolean

On this page