ox_lib compatibility ​
np_menu runs alongside ox_lib and doesn't depend on it. If your resources already use ox_lib menus, an optional layer maps the ox_lib signatures onto np_menu so they render in the Nimbus look without a rewrite.
lua
Config.OxCompat = true
It adds these exports to np_menu (and NpMenu.Compat.<name> inside np_menu):
| ox_lib | np_menu export | Notes |
|---|---|---|
lib.registerMenu(data, cb) |
registerMenu(data, cb) |
Registered as ox:menu:<id>. values → list row, checked → checkbox, progress → info, everything else → button. onSideScroll, onCheck, onSelected and onClose are called with ox arguments |
lib.showMenu(id, startIndex?) |
showMenu(id, startIndex?) |
|
lib.hideMenu(onExit?) |
hideMenu(onExit?) |
hideMenu() closes without firing onClose, like ox |
lib.getOpenMenu() |
getOpenMenu() |
|
lib.setMenuOptions(id, options, index?) |
setMenuOptions(id, options, index?) |
|
lib.registerContext(context | contexts) |
registerContext(...) |
Registered as ox:ctx:<id>, rendered as a list menu (ox "context" menus are centred lists, not world-anchored) |
lib.showContext(id) |
showContext(id) |
Rebuilds the menu = 'parent' chain so Backspace goes to the parent |
lib.hideContext(onExit?) |
hideContext(onExit?) |
|
lib.getOpenContextMenu() |
getOpenContextMenu() |
|
lib.inputDialog(heading, rows, options?) |
inputDialog(heading, rows, options?) |
Returns an array like ox. Unset values are false so the array stays dense |
lib.alertDialog(data) |
alertDialog(data) |
Returns 'confirm' or 'cancel' |
lib.addRadialItem(item | items) |
addRadialItem(...) |
Added to the global radial context as ox:<id>. menu opens the matching registerContext menu |
lib.removeRadialItem(id) |
removeRadialItem(id) |
showContext and inputDialog share their export names with the core: the export looks at the arguments.
showContext('someOxId') (a string with no target, registered through registerContext) uses the ox behaviour;
showContext(def, entity) is the np_menu world-anchored menu. inputDialog('Heading', rows) (a string first) is the
ox form; inputDialog({ … }) is np_menu's.
Example ​
lua
-- unchanged ox_lib-style code, pointed at np_menu
local menu = exports.np_menu
menu:registerContext({
id = 'garage',
title = 'Garage',
options = {
{ title = 'Take out', icon = 'car', onSelect = function() print('take out') end },
{ title = 'Store', icon = 'warehouse', serverEvent = 'garage:store' },
{ title = 'Impound', menu = 'garage_impound' },
},
})
menu:showContext('garage')
local input = menu:inputDialog('Transfer', {
{ type = 'number', label = 'Amount', min = 1, required = true },
{ type = 'select', label = 'Account', options = { { label = 'Bank', value = 'bank' } } },
})
Mapping notes ​
- Input row types:
input→ text (password = true→ password),number,checkbox,select,color,textarea.sliderbecomes a number field,multi-selecta single select,dateandtimeplain text. - Option
icons must be Font Awesome names as strings. Other icon formats are dropped. menu.positionstrings containingleft/rightmap to np_menu's left / right; anything else uses the player setting.- Context options support
onSelect,event,serverEvent,args,menu,readOnly,disabled,progress(as a right label) andkeepOpen. - Nothing is overridden in ox_lib itself. To route
lib.*calls from existing resources to np_menu, wrap them in your own code or replace the calls withexports.np_menu:<name>.