OPX//77
opx_lib

opx_lib

Last updated on

A client-only Lua library any resource can require — how to load it, the permission each module needs, and the Result every wrapper answers.

opx_lib is a separate resource. Its wrappers call Open77 natives and answer a Result instead of raising (markers, blips, key bindings, cameras, screen fades, callbacks, raycasts). Its pure helpers cover text, numbers, tables, colours and translations. opx_infinity loads it once on its client and exposes it as OPX.Lib. Version 0.4.0 (Lib.VERSION).

Using it

open77.lua
dependency "opx_lib"
permissions { "world.markers", "input.actions" }  -- only what you use, see below
client/main.lua
local Lib = require('@opx_lib')
local name = Lib.Validate.Word(payload.name, 24)
Lib.Notify.Show('Welcome, ' .. name)
FactDetail
Client onlyThe server sandbox has no require, so no server script can load it. To use a pure/ helper on the server, copy the file.
Runs in your VMThe code runs inside the resource that calls require. Your permissions, your instruction budget, and every marker, blip, key mapping or callback it creates belongs to you.
Permissionsopx_lib declares none: a permission is checked against the calling resource. You declare what you use. A missing one comes back as error = 'permission_denied' with a detail naming the line to add.
Per resourceEach resource that requires it gets its own copy of every table. Lib.Locale's catalogue is yours alone.
Without dependency "opx_lib"require answers nil, 'module_dependency_not_declared'.
Server sideopx_lib's own server script only logs that it is present.

Manifest helpers

Lib.VERSION

The library version.

Lib.VERSION -- '0.4.0'
  • string

Lib.NEEDS

Each module's NEEDS, read off the modules (Lib.Permission.Of).

Lib.NEEDS -- { Notify = 'ui.vanilla.hud', Input = 'input.actions', ... }
  • table<module, permission>

Lib.Manifest

The permissions { ... } line that covers every module. Print it at start-up to check yours.

Lib.Manifest()

Returns

  • string? — nil when nothing is needed
Example
print(Lib.Manifest())

Permission per module

ModulePermission you declare
Notifyui.vanilla.hud
Inputinput.actions
Markerworld.markers (not for Shapes)
Callbacknetwork.events
Worldworld.query
Blipui.vanilla.map
Cameracamera.script (not for Ray, Owner)
Screenscreen.effects
every other modulenone

Results

Almost every wrapper answers a Result:

{ ok = true, value = v }
{ ok = false, error = code, detail = text }
  • Common codes from any wrapper: open77_unavailable, native_not_found (older build), native_raised, permission_denied, or the native's own refusal string.
  • Validation codes (invalid_*) are listed per function.
  • A function marked Yields must run inside CreateThread.

Modules

Pure modules

No natives and no permission. Same behaviour on any runtime.

Result · Validate · Table · String · Math · Class · Locale · Text · Array · Colour · Permission

Client modules

Wrappers over Open77 natives, client only.

Native · Timer · Character · Notify · Anim · Input · Marker · Callback · Zone · Rpc · Async · World · Players · Blip · Store · Camera · Screen

On this page