autodoc_functions_functions
Constructor > <BadgeClient /> jo.menu.create() > Syntax
jo.menu.create(id, data)
Constructor > <BadgeClient /> jo.menu.create() > Parameters
id : string
Unique ID of the menu
data : table <BadgeOptional />
Menu configuration data
data.title: string - The big title of the menu
data.subtitle: string - The subtitle of the menu
data.numberOnScreen: integer - Maximum number of items visibles at the same time <br> default :8<BadgeOptional />
data.distanceToClose: float - Distance at which the menu will self close if the player is moving away <br> default:false
data.onEnter: function - Fired when the menu is opened <BadgeOptional />
data.onBack: function - Fired when the backspace/Escape is pressed <BadgeOptional />
data.onExit: function - Fired when the menu is exited <BadgeOptional />
data.onTick: function - Fired every tick <BadgeOptional />
Constructor > <BadgeClient /> jo.menu.create() > Return Value
Type : MenuClass
The newly created menu object
Constructor > <BadgeClient /> jo.menu.create() > Example
--The unique ID of the menu
local id = "UniqueId1"
--The menu data
local data = {
title = "Menu", --The big title of the menu
subtitle = "Elements", --The subtitle of the menu
numberOnScreen = 8, --The number of item display before add a scroll
onEnter = function(currentData)
print("Enter in menu " .. id)
end,
onBack = function(currentData)
print("Backspace/Esc pressed in menu " .. id)
end,
onExit = function(currentData)
print("Exit menu " .. id)
end,
}
local menu = jo.menu.create(id, data)
MenuClass Methods > <BadgeClient /> MenuClass:addItem() > Syntax
MenuClass:addItem(index, item)
MenuClass Methods > <BadgeClient /> MenuClass:addItem() > Parameters
index : integer|table
Position index or item table if used as single parameter
item : table <BadgeOptional />
The item to add - if not provided, p is used as the item
item.title: string - The item label
item.child: string - The menu to open when Enter is pressed <br> default: false <BadgeOptional />
item.visible: boolean - If the item is visible in the menu <br> default: true <BadgeOptional />
item.data: table - Variable to store custom data in the item <BadgeOptional />
item.description: string - Description text for the item <BadgeOptional />
item.prefix: string - The little icon before the title fromnui\menu\assets\images\iconsfolder<BadgeOptional />
item.icon: string - The left icon filename fromnui\menu\assets\images\iconsfolder<BadgeOptional />
item.iconRight: string - The right icon filename fromnui\menu\assets\images\iconsfolder<BadgeOptional />
item.iconClass: string - CSS class for the icon <BadgeOptional />
item.price: table - The price of the item. Use 0 to display "free" <br> default: false<BadgeOptional />
item.price.money: number - The price in $ <BadgeOptional />
item.price.gold: number - The price in gold <BadgeOptional />
item.priceTitle: string - Replace the "Price" label <BadgeOptional />
item.priceRight: boolean - Display the price at the right of the item title<BadgeOptional />
item.statistics: table - List of statistics to display for the item <BadgeOptional />
item.disabled: boolean - If the item is disabled (grey) in the menu<BadgeOptional />
item.textRight: string - The label displayed at the right of the item<BadgeOptional />
item.previewPalette: boolean - Display a color square at the right of the item <br> default: true<BadgeOptional />
item.sliders: table - List of sliders for the item <BadgeOptional />
item.onActive: function - Fired when the item is selected <BadgeOptional />
item.onClick: function - Fired when Enter is pressed on the item <BadgeOptional />
item.onChange: function - Fired when a slider value changes <BadgeOptional />
item.onExit: function - Fired when the item is exited <BadgeOptional />
item.onTick: function - Fired every tick <BadgeOptional />
MenuClass Methods > <BadgeClient /> MenuClass:addItem() > Return Value
Type : MenuItemClass
The added item
MenuClass Methods > <BadgeClient /> MenuClass:addItem() > Example
-- Create a menu
local menu = jo.menu.create("shopMenu", {
title = "General Store",
subtitle = "Available Items"
})
-- Add items using single parameter (adds to the end of the list)
menu:addItem({
title = "Hunting Knife",
description = "A sharp knife for skinning animals",
prefix = "knife", -- Icon before the title
price = { money = 12.50 },
statistics = {
{ label = "Damage", type = "bar", value = { 7, 10 } },
{ label = "Durability", type = "bar", value = { 8, 10 } }
},
onClick = function(currentData)
print("Purchasing Hunting Knife")
-- Code to purchase the item would go here
end
})
-- Add item at specific position (position 1 - at the beginning)
menu:addItem(1, {
title = "Horse Brush",
description = "Keep your horse clean and happy",
price = { money = 5.75 },
icon = "brush", -- Left icon
disabled = false,
textRight = "New!", -- Text shown on the right
onClick = function(currentData)
print("Purchasing Horse Brush")
-- Code to purchase the item would go here
end
})
-- Add another item with sliders
menu:addItem({
title = "Hunting Outfit",
description = "Camouflage clothing for hunting",
price = { money = 45.00, gold = 5 },
sliders = {
{
title = "Colors",
current = 1,
values = { "Brown", "Green", "Black" }
}
},
onChange = function(currentData)
local selectedColor = currentData.item.sliders[1].value.label
print("Selected color: " .. selectedColor)
end
})
-- Add a child menu item (opens another menu when selected)
menu:addItem({
title = "Weapons →",
child = "weaponsMenu", -- This will open the "weaponsMenu" when activated
icon = "revolver"
})
-- Send the menu to the NUI layer
menu:send()
-- Set this menu as the current menu and show it
jo.menu.setCurrentMenu("shopMenu")
jo.menu.show(true)
MenuClass Methods > <BadgeClient /> MenuClass:deleteValue()
Delete a specific property of a menu. Requires MenuClass:push() to be called to apply the changes <br>
MenuClass Methods > <BadgeClient /> MenuClass:deleteValue() > Syntax
MenuClass:deleteValue(keys)
MenuClass Methods > <BadgeClient /> MenuClass:deleteValue() > Parameters
keys : string|table
The list of property name to access to the value
MenuClass Methods > <BadgeClient /> MenuClass:deleteValue() > Example
menu:deleteValue("key")
MenuClass Methods > <BadgeClient /> MenuClass:push()
Push the updated values to the NUI layer <br>
MenuClass Methods > <BadgeClient /> MenuClass:push() > Syntax
MenuClass:push()
MenuClass Methods > <BadgeClient /> MenuClass:push() > Example
-- Update the title of the 3rd item in a menu
menu:updateValue({"items",3, "title"}, "New Title")
-- Update the NUI
menu:push()
MenuClass Methods > <BadgeClient /> MenuClass:refresh()
Refresh all the menu without changing the current state <br> Used when you want rebuild the menu <br>
MenuClass Methods > <BadgeClient /> MenuClass:refresh() > Syntax
MenuClass:refresh()
MenuClass Methods > <BadgeClient /> MenuClass:refresh() > Example
local menu = jo.menu.create(id, data)
menu:addItem({ title = "Item 1" })
menu:send()
menu:addItem({ title = "Item 2" })
menu:refresh()
MenuClass Methods > <BadgeClient /> MenuClass:removeItem()
Remove an item from a menu by its index. Requires MenuClass:push() to be called to apply the changes <br>
MenuClass Methods > <BadgeClient /> MenuClass:removeItem() > Syntax
MenuClass:removeItem(index)
MenuClass Methods > <BadgeClient /> MenuClass:removeItem() > Parameters
index : integer
The index of the item to remove
MenuClass Methods > <BadgeClient /> MenuClass:removeItem() > Example
-- Remove the 2nd slider from the 1st item
menu:removeItem({"items", 1, "sliders", 2})
-- Update the NUI
menu:push()
MenuClass Methods > <BadgeClient /> MenuClass:reset()
Reset the menu to its initial state <br> Moves the cursor back to the first item <br>
MenuClass Methods > <BadgeClient /> MenuClass:reset() > Syntax
MenuClass:reset()
MenuClass Methods > <BadgeClient /> MenuClass:reset() > Example
menu:reset()
MenuClass Methods > <BadgeClient /> MenuClass:send()
Send the menu data to the NUI layer <br>
MenuClass Methods > <BadgeClient /> MenuClass:send() > Syntax
MenuClass:send()
MenuClass Methods > <BadgeClient /> MenuClass:send() > Example
local menu = jo.menu.create(id, data)
menu:send()
MenuClass Methods > <BadgeClient /> MenuClass:setCurrentIndex()
Change the current active item index <br>
MenuClass Methods > <BadgeClient /> MenuClass:setCurrentIndex() > Syntax
MenuClass:setCurrentIndex(index)
MenuClass Methods > <BadgeClient /> MenuClass:setCurrentIndex() > Parameters
index : integer
The item index to switch to
MenuClass Methods > <BadgeClient /> MenuClass:setCurrentIndex() > Example
local menu = jo.menu.create(id, data)
menu:addItem({
title = "Item 1",
})
menu:addItem({
title = "Item 2",
})
menu:addItem({
title = "Item 3",
})
menu:setCurrentIndex(2) -- set item 2 as active
MenuClass Methods > <BadgeClient /> MenuClass:sort()
Sort menu items alphabetically by title <br>
MenuClass Methods > <BadgeClient /> MenuClass:sort() > Syntax
MenuClass:sort(first, last)
MenuClass Methods > <BadgeClient /> MenuClass:sort() > Parameters
first : integer <BadgeOptional />
Position of the first element to sort <br> default:
1
last : integer <BadgeOptional />
Position of the last element to sort <br> default:
#self.items
MenuClass Methods > <BadgeClient /> MenuClass:sort() > Example
-- Sort all menu items alphabetically by title
menu:sort()
-- Sort only items 2 through 5
menu:sort(2, 5)
MenuClass Methods > <BadgeClient /> MenuClass:updateValue()
Update a specific property of a menu. Requires MenuClass:push() to be called to apply the changes <br>
MenuClass Methods > <BadgeClient /> MenuClass:updateValue() > Syntax
MenuClass:updateValue(keys, value)
MenuClass Methods > <BadgeClient /> MenuClass:updateValue() > Parameters
keys : string|table
The list of property name to access to the value
value : any
The new value
MenuClass Methods > <BadgeClient /> MenuClass:updateValue() > Example
-- Update the title of the 3rd item in a menu
menu:updateValue({"items",3, "title"}, "New Title")
-- Update the NUI
menu:push()
MenuClass Methods > <BadgeClient /> MenuClass:use()
Set this menu as the current active menu <br>
MenuClass Methods > <BadgeClient /> MenuClass:use() > Syntax
MenuClass:use(keepHistoric, resetMenu)
MenuClass Methods > <BadgeClient /> MenuClass:use() > Parameters
keepHistoric : boolean <BadgeOptional />
Whether to keep navigation history <br> default:
true
resetMenu : boolean <BadgeOptional />
Whether to reset the menu state <br> default:
true
MenuClass Methods > <BadgeClient /> MenuClass:use() > Example
-- Set this menu as the current active menu
-- Keep navigation history and reset the cursor position
menu:use(true, true)
-- Set this menu as the current active menu
-- Don't keep navigation history
menu:use(false)
MenuClass Methods > <BadgeClient /> MenuClass:updateItem()
:::danger Deprecated since v2.3.0. Use MenuClass:updateValue or MenuClass:deleteValue instead :::
Update a specific property of a menu item <br>
MenuClass Methods > <BadgeClient /> MenuClass:updateItem() > Syntax
MenuClass:updateItem(index, key, value)
MenuClass Methods > <BadgeClient /> MenuClass:updateItem() > Parameters
index : integer
The index of the item to update
key : string
The property name to update
value : any
The new value for the property
MenuClass Methods > <BadgeClient /> MenuClass:updateItem() > Example
-- Update the title of the second item
menu:updateItem(2, "title", "New Title")
-- Disable the third item
menu:updateItem(3, "disabled", true)
MenuItem Methods > <BadgeClient /> MenuItem:deleteValue()
Delete a specific property of a menu item. Requires MenuClass:push() to be called to apply the changes <br>
MenuItem Methods > <BadgeClient /> MenuItem:deleteValue() > Syntax
MenuItem:deleteValue(keys)
MenuItem Methods > <BadgeClient /> MenuItem:deleteValue() > Parameters
keys : string|table
The list of property name to access to the value
MenuItem Methods > <BadgeClient /> MenuItem:deleteValue() > Example
-- Remove the 2nd slider of the item
item:deleteValue({"sliders", 2})
-- Update the NUI
menu:push()
MenuItem Methods > <BadgeClient /> MenuItem:getParentMenu() > Syntax
MenuItem:getParentMenu()
MenuItem Methods > <BadgeClient /> MenuItem:getParentMenu() > Return Value
Type : MenuClass
The parent menu
MenuItem Methods > <BadgeClient /> MenuItem:getParentMenu() > Example
local parentMenu = item:getParentMenu()
print(parentMenu.title)
MenuItem Methods > <BadgeClient /> MenuItem:updateValue()
Update a specific property of a menu item. Requires MenuClass:push() to be called to apply the changes <br>
MenuItem Methods > <BadgeClient /> MenuItem:updateValue() > Syntax
MenuItem:updateValue(keys, value)
MenuItem Methods > <BadgeClient /> MenuItem:updateValue() > Parameters
keys : string|table
The property name to update
value : any
The new value for the property
MenuItem Methods > <BadgeClient /> MenuItem:updateValue() > Example
-- Update the title of the 3rd slider of the item
item:updateValue({"sliders",3, "title"}, "New Title")
-- Update the NUI
menu:push()
JO Functions > <BadgeClient /> jo.menu.addItem() > Syntax
jo.menu.addItem(id, p, item)
JO Functions > <BadgeClient /> jo.menu.addItem() > Parameters
id : string
The menu ID
p : integer|table
Position index or item table if used as single parameter
item : table <BadgeOptional />
The item to add - if not provided, p is used as the item
item.title: string - The item label
item.child: string - The menu to open when Enter is pressed <br> default: false <BadgeOptional />
item.visible: boolean - If the item is visible in the menu <br> default: true <BadgeOptional />
item.data: table - Variable to store custom data in the item <BadgeOptional />
item.description: string - Description text for the item <BadgeOptional />
item.prefix: string - The little icon before the title fromnui\menu\assets\images\iconsfolder<BadgeOptional />
item.icon: string - The left icon filename fromnui\menu\assets\images\iconsfolder<BadgeOptional />
item.iconRight: string - The right icon filename fromnui\menu\assets\images\iconsfolder<BadgeOptional />
item.iconClass: string - CSS class for the icon <BadgeOptional />
item.price: table - The price of the item. Use 0 to display "free" <br> default: false<BadgeOptional />
item.price.money: number - The price in $ <BadgeOptional />
item.price.gold: number - The price in gold <BadgeOptional />
item.priceTitle: string - Replace the "Price" label <BadgeOptional />
item.priceRight: boolean - Display the price at the right of the item title<BadgeOptional />
item.statistics: table - List of statistics to display for the item <BadgeOptional />
item.disabled: boolean - If the item is disabled (grey) in the menu<BadgeOptional />
item.textRight: string - The label displayed at the right of the item<BadgeOptional />
item.previewPalette: boolean - Display a color square at the right of the item <br> default: true<BadgeOptional />
item.sliders: table - List of sliders for the item <BadgeOptional />
item.onActive: function - Fired when the item is selected <BadgeOptional />
item.onClick: function - Fired when Enter is pressed on the item <BadgeOptional />
item.onChange: function - Fired when a slider value changes <BadgeOptional />
item.onExit: function - Fired when the item is exited <BadgeOptional />
JO Functions > <BadgeClient /> jo.menu.addItem() > Example
-- Add a new item to a menu by its ID
local menuId = "mainMenu"
jo.menu.addItem(menuId, {
title = "New Option",
description = "This is a new menu option",
onClick = function(currentData)
print("New option clicked")
end
})
-- Add a new item at a specific position (3rd position)
jo.menu.addItem(menuId, 3, {
title = "Insert at position 3",
description = "This item will be inserted at position 3"
})
JO Functions > <BadgeClient /> jo.menu.delete() > Syntax
jo.menu.delete(id)
JO Functions > <BadgeClient /> jo.menu.delete() > Parameters
id : string
The menu ID to delete
JO Functions > <BadgeClient /> jo.menu.delete() > Example
local id = "UniqueId1"
jo.menu.delete(id)
JO Functions > <BadgeClient /> jo.menu.displayLoader() > Syntax
jo.menu.displayLoader(value)
JO Functions > <BadgeClient /> jo.menu.displayLoader() > Parameters
value : boolean <BadgeOptional />
Whether to display the loader <br> default:
true
JO Functions > <BadgeClient /> jo.menu.displayLoader() > Example
jo.menu.displayLoader()
Wait(3000)
jo.menu.hideLoader()
JO Functions > <BadgeClient /> jo.menu.doesActiveButtonChange()
Check if the active button has changed since last update <br>
JO Functions > <BadgeClient /> jo.menu.doesActiveButtonChange() > Syntax
jo.menu.doesActiveButtonChange()
JO Functions > <BadgeClient /> jo.menu.doesActiveButtonChange() > Return Value
Type : boolean
Returns
trueif the active button has changed
JO Functions > <BadgeClient /> jo.menu.doesActiveButtonChange() > Example
-- Check if the selected button has changed since last update
if jo.menu.doesActiveButtonChange() then
print("Player selected a different button")
end
JO Functions > <BadgeClient /> jo.menu.fireAllLevelsEvent()
Fire an event across all menu levels (current menu and current item) <br>
JO Functions > <BadgeClient /> jo.menu.fireAllLevelsEvent() > Syntax
jo.menu.fireAllLevelsEvent(eventName, ...)
JO Functions > <BadgeClient /> jo.menu.fireAllLevelsEvent() > Parameters
eventName : string
The name of the event to fire
... : any <BadgeOptional />
Additional arguments to pass to the event handlers
JO Functions > <BadgeClient /> jo.menu.fireAllLevelsEvent() > Example
-- Fire a custom event across all menu levels
jo.menu.fireAllLevelsEvent("onCustomEvent", "Parameter 1", 42, { data = "Extra data" })
JO Functions > <BadgeClient /> jo.menu.fireEvent()
Fire an event for a specific menu item <br>
JO Functions > <BadgeClient /> jo.menu.fireEvent() > Syntax
jo.menu.fireEvent(item, eventName, ...)
JO Functions > <BadgeClient /> jo.menu.fireEvent() > Parameters
item : table
The item to trigger the event on
eventName : string
The name of the event to fire
... : any <BadgeOptional />
Additional arguments to pass to the event handler
JO Functions > <BadgeClient /> jo.menu.fireEvent() > Example
-- Get the current item and fire a custom event on it
local currentItem = jo.menu.getCurrentItem()
jo.menu.fireEvent(currentItem, "onClick")
-- Fire a custom event on a specific menu
local menu = jo.menu.get("mainMenu")
jo.menu.fireEvent(menu, "onExit")
JO Functions > <BadgeClient /> jo.menu.forceBack()
Force the menu to go back to the previous menu <br>
JO Functions > <BadgeClient /> jo.menu.forceBack() > Syntax
jo.menu.forceBack()
JO Functions > <BadgeClient /> jo.menu.forceBack() > Example
-- Force the menu to go back to the previous menu
jo.menu.forceBack()
JO Functions > <BadgeClient /> jo.menu.get() > Syntax
jo.menu.get(id)
JO Functions > <BadgeClient /> jo.menu.get() > Parameters
id : string
The menu ID
JO Functions > <BadgeClient /> jo.menu.get() > Return Value
Type : MenuClass
The menu object
JO Functions > <BadgeClient /> jo.menu.get() > Example
-- Get a menu instance by its ID
local menuId = "mainMenu"
local menu = jo.menu.get(menuId)
-- Now you can work with this menu instance
if menu then
print("Menu title: " .. menu.title)
print("Number of items: " .. #menu.items)
end
JO Functions > <BadgeClient /> jo.menu.getCurrentData()
Get data about the current menu state <br>
JO Functions > <BadgeClient /> jo.menu.getCurrentData() > Syntax
jo.menu.getCurrentData()
JO Functions > <BadgeClient /> jo.menu.getCurrentData() > Return Value
Type : table
Current menu data including menu ID and selected item
JO Functions > <BadgeClient /> jo.menu.getCurrentData() > Example
-- Get data about the current menu state
local currentData = jo.menu.getCurrentData()
print("Current menu ID: " .. tostring(currentData.menu))
print("Current item index: " .. tostring(currentData.index))
JO Functions > <BadgeClient /> jo.menu.getCurrentIndex()
A function to get the current index <br>
JO Functions > <BadgeClient /> jo.menu.getCurrentIndex() > Syntax
jo.menu.getCurrentIndex()
JO Functions > <BadgeClient /> jo.menu.getCurrentIndex() > Return Value
Type : integer
The index of the current item
JO Functions > <BadgeClient /> jo.menu.getCurrentIndex() > Example
local currentIndex = jo.menu.getCurrentIndex()
print(currentIndex)
JO Functions > <BadgeClient /> jo.menu.getCurrentItem()
Get the currently selected menu item <br>
JO Functions > <BadgeClient /> jo.menu.getCurrentItem() > Syntax
jo.menu.getCurrentItem()
JO Functions > <BadgeClient /> jo.menu.getCurrentItem() > Return Value
Type : table
The currently selected item
JO Functions > <BadgeClient /> jo.menu.getCurrentItem() > Example
-- Get the currently selected menu item
local currentItem = jo.menu.getCurrentItem()
-- Access properties of the current item
if currentItem then
print("Selected item: " .. currentItem.title)
if currentItem.description then
print("Description: " .. currentItem.description)
end
end
JO Functions > <BadgeClient /> jo.menu.getCurrentMenu() > Syntax
jo.menu.getCurrentMenu()
JO Functions > <BadgeClient /> jo.menu.getCurrentMenu() > Return Value
Type : MenuClass
The currently active menu
JO Functions > <BadgeClient /> jo.menu.getCurrentMenu() > Example
-- Get the currently active menu
local currentMenu = jo.menu.getCurrentMenu()
-- Access properties of the current menu
if currentMenu then
print("Active menu title: " .. currentMenu.title)
print("Number of items: " .. #currentMenu.items)
end
JO Functions > <BadgeClient /> jo.menu.getCurrentMenuId()
A function to get the current menu id <br>
JO Functions > <BadgeClient /> jo.menu.getCurrentMenuId() > Syntax
jo.menu.getCurrentMenuId()
JO Functions > <BadgeClient /> jo.menu.getCurrentMenuId() > Return Value
Type : string
The id of the current menu
JO Functions > <BadgeClient /> jo.menu.getCurrentMenuId() > Example
local currentMenuId = jo.menu.getCurrentMenuId()
print(currentMenuId)
JO Functions > <BadgeClient /> jo.menu.getPreviousData()
Get data about the previous menu state <br>
JO Functions > <BadgeClient /> jo.menu.getPreviousData() > Syntax
jo.menu.getPreviousData()
JO Functions > <BadgeClient /> jo.menu.getPreviousData() > Return Value
Type : table
Previous menu data including menu ID and selected item
JO Functions > <BadgeClient /> jo.menu.getPreviousData() > Example
-- Get data about the previous menu state
local previousData = jo.menu.getPreviousData()
print("Previous menu ID: " .. tostring(previousData.menu))
print("Previous item index: " .. tostring(previousData.index))
JO Functions > <BadgeClient /> jo.menu.hideLoader() > Syntax
jo.menu.hideLoader()
JO Functions > <BadgeClient /> jo.menu.hideLoader() > Example
jo.menu.displayLoader()
Wait(3000)
jo.menu.hideLoader()
JO Functions > <BadgeClient /> jo.menu.isCurrentMenu()
A function to know if the menu is the current one <br>
JO Functions > <BadgeClient /> jo.menu.isCurrentMenu() > Syntax
jo.menu.isCurrentMenu(id)
JO Functions > <BadgeClient /> jo.menu.isCurrentMenu() > Parameters
id : string
The menu id
JO Functions > <BadgeClient /> jo.menu.isCurrentMenu() > Return Value
Type : boolean
JO Functions > <BadgeClient /> jo.menu.isCurrentMenu() > Example
local menuId = "home"
local isCurrentMenu = jo.menu.isCurrentMenu(menuId)
print(isCurrentMenu)
-- Expected output: `true` if the "home" menu is active, else `false`
JO Functions > <BadgeClient /> jo.menu.isExist() > Syntax
jo.menu.isExist(id)
JO Functions > <BadgeClient /> jo.menu.isExist() > Parameters
id : string
the menu ID
JO Functions > <BadgeClient /> jo.menu.isExist() > Return Value
Type : boolean
Returns
trueif the menu exists
JO Functions > <BadgeClient /> jo.menu.isExist() > Example
local menuId = "home"
local isExist = jo.menu.isExist(menuId)
-- Expected output: `true` if the menu was created before, else `false`
JO Functions > <BadgeClient /> jo.menu.isOpen()
Check if any menu is currently open <br>
JO Functions > <BadgeClient /> jo.menu.isOpen() > Syntax
jo.menu.isOpen()
JO Functions > <BadgeClient /> jo.menu.isOpen() > Return Value
Type : boolean
Returns
trueif a menu is open
JO Functions > <BadgeClient /> jo.menu.isOpen() > Example
local isOpen = jo.menu.isOpen()
print(isOpen)
JO Functions > <BadgeClient /> jo.menu.missingMenuHandler()
<br> <br> Register a handler for missing menu error <br>
JO Functions > <BadgeClient /> jo.menu.missingMenuHandler() > Syntax
jo.menu.missingMenuHandler(id, callback)
JO Functions > <BadgeClient /> jo.menu.missingMenuHandler() > Parameters
id : string
The menu ID
callback : function
The handler function
JO Functions > <BadgeClient /> jo.menu.missingMenuHandler() > Example
jo.menu.missingMenuHandler('home', function()
print('home menu is missing')
local menu = jo.menu.create('home', {
title = "home"
})
menu:addItem({title = "item"})
menu:send()
menu:use()
end)
JO Functions > <BadgeClient /> jo.menu.onChange()
Register a callback function for menu change events <br>
JO Functions > <BadgeClient /> jo.menu.onChange() > Syntax
jo.menu.onChange(cb)
JO Functions > <BadgeClient /> jo.menu.onChange() > Parameters
cb : function
The callback function to register
JO Functions > <BadgeClient /> jo.menu.onChange() > Example
-- Register a callback function for menu change events
jo.menu.onChange(function(currentData)
print("Menu changed to: " .. tostring(currentData.menu))
print("Selected item: " .. tostring(currentData.item.title))
-- You can handle different menus here
if currentData.menu == "mainMenu" then
-- Do something specific for the main menu
elseif currentData.menu == "settingsMenu" then
-- Do something specific for the settings menu
end
end)
JO Functions > <BadgeClient /> jo.menu.playAudio() > Syntax
jo.menu.playAudio(sound)
JO Functions > <BadgeClient /> jo.menu.playAudio() > Parameters
sound : string
JO Functions > <BadgeClient /> jo.menu.playAudio() > Example
jo.menu.playAudio('coins')
JO Functions > <BadgeClient /> jo.menu.refresh() > Syntax
jo.menu.refresh(id)
JO Functions > <BadgeClient /> jo.menu.refresh() > Parameters
id : string
The menu ID to refresh
JO Functions > <BadgeClient /> jo.menu.refresh() > Example
-- Refresh a menu by its ID to update its display
local menuId = "mainMenu"
jo.menu.refresh(menuId)
JO Functions > <BadgeClient /> jo.menu.reset() > Syntax
jo.menu.reset(id)
JO Functions > <BadgeClient /> jo.menu.reset() > Parameters
id : string
The menu ID to reset
JO Functions > <BadgeClient /> jo.menu.reset() > Example
-- Reset a menu by its ID
-- This moves the cursor back to the first item
local menuId = "mainMenu"
jo.menu.reset(menuId)
JO Functions > <BadgeClient /> jo.menu.runRefreshEvents()
A function to fire menu and items events <br>
JO Functions > <BadgeClient /> jo.menu.runRefreshEvents() > Syntax
jo.menu.runRefreshEvents(menuEvent, itemEvent)
JO Functions > <BadgeClient /> jo.menu.runRefreshEvents() > Parameters
menuEvent : boolean <BadgeOptional />
Whether to run menu events
itemEvent : boolean <BadgeOptional />
Whether to run item events
JO Functions > <BadgeClient /> jo.menu.runRefreshEvents() > Example
local fireMenuEvents = false
local fireItemEvents = true
jo.menu.runRefreshEvents(fireMenuEvents, fireItemEvents)
JO Functions > <BadgeClient /> jo.menu.send()
Send a menu to the NUI layer by its ID <br>
JO Functions > <BadgeClient /> jo.menu.send() > Syntax
jo.menu.send(id)
JO Functions > <BadgeClient /> jo.menu.send() > Parameters
id : string
The menu ID
JO Functions > <BadgeClient /> jo.menu.send() > Example
-- Send a menu to the NUI layer by its ID
local menuId = "mainMenu"
jo.menu.send(menuId)
-- Send without resetting cursor position
jo.menu.send(menuId, false)
JO Functions > <BadgeClient /> jo.menu.set() > Syntax
jo.menu.set(id, menu)
JO Functions > <BadgeClient /> jo.menu.set() > Parameters
id : string
The menu ID
menu : MenuClass
The menu object to set
JO Functions > <BadgeClient /> jo.menu.set() > Example
-- Create a new menu instance
local newMenu = {
id = "customMenu",
title = "Custom Menu",
subtitle = "Created with jo.menu.set",
items = {
{ title = "Option 1" },
{ title = "Option 2" }
}
}
-- Set this as a menu by its ID
jo.menu.set("customMenu", newMenu)
JO Functions > <BadgeClient /> jo.menu.setCurrentMenu()
Set a menu as the current active menu <br>
JO Functions > <BadgeClient /> jo.menu.setCurrentMenu() > Syntax
jo.menu.setCurrentMenu(id, keepHistoric, resetMenu)
JO Functions > <BadgeClient /> jo.menu.setCurrentMenu() > Parameters
id : string
ID of the menu to activate
keepHistoric : boolean <BadgeOptional />
Keep the menu navigation history <br> default:
true
resetMenu : boolean <BadgeOptional />
Clear and redraw the menu before displaying <br> default:
true
JO Functions > <BadgeClient /> jo.menu.setCurrentMenu() > Example
local id = "UniqueId1"
local keepHistoric = true
local resetMenu = true
jo.menu.setCurrentMenu(id, keepHistoric, resetMenu)
JO Functions > <BadgeClient /> jo.menu.show() > Syntax
jo.menu.show(show, keepInput, hideRadar, animation, hideCursor)
JO Functions > <BadgeClient /> jo.menu.show() > Parameters
show : boolean
Whether to show or hide the menu
keepInput : boolean <BadgeOptional />
Whether to keep game input controls active <br> default:
true
hideRadar : boolean <BadgeOptional />
Whether to hide the radar when menu is shown <br> default:
true
animation : boolean <BadgeOptional />
Whether to use animation when showing/hiding the menu <br> default:
true
hideCursor : boolean <BadgeOptional />
Whether to hide the cursor <br> default:
false
JO Functions > <BadgeClient /> jo.menu.show() > Example
local visible = true
local keepInput = true
local hideRadar = true
jo.menu.show(visible, keepInput, hideRadar)
JO Functions > <BadgeClient /> jo.menu.softHide()
A function to hide temporary the menu and do action <br>
JO Functions > <BadgeClient /> jo.menu.softHide() > Syntax
jo.menu.softHide(cb, animation)
JO Functions > <BadgeClient /> jo.menu.softHide() > Parameters
cb : function
Action executed before show again the menu
animation : boolean <BadgeOptional />
Whether to use animation when showing/hiding the menu <br> default:
true
JO Functions > <BadgeClient /> jo.menu.softHide() > Example
menu:addItem({
title = "Title",
onClick = function(currentData)
jo.menu.softHide(function()
local title = jo.input.native("Enter the new title", currentData.item.title, 100)
if title then
currentData.item.title = title
menu:refresh()
end
end)
end
})
JO Functions > <BadgeClient /> jo.menu.sort()
Sort menu items alphabetically by title using menu ID <br>
JO Functions > <BadgeClient /> jo.menu.sort() > Syntax
jo.menu.sort(id, first, last)
JO Functions > <BadgeClient /> jo.menu.sort() > Parameters
id : string
The menu ID
first : integer <BadgeOptional />
Position of the first element to sort <br> default:
1
last : integer <BadgeOptional />
Position of the last element to sort <br> default:
#self.items
JO Functions > <BadgeClient /> jo.menu.sort() > Example
-- Sort all items in a menu alphabetically by title
local menuId = "mainMenu"
jo.menu.sort(menuId)
-- Sort only items 2 through 5
jo.menu.sort(menuId, 2, 5)
JO Functions > <BadgeClient /> jo.menu.updateItem()
Update a specific property of a menu item by menu ID <br>
JO Functions > <BadgeClient /> jo.menu.updateItem() > Syntax
jo.menu.updateItem(id, index, key, value)
JO Functions > <BadgeClient /> jo.menu.updateItem() > Parameters
id : string
The menu ID
index : integer
The index of the item to update
key : string
The property name to update
value : any
The new value for the property
JO Functions > <BadgeClient /> jo.menu.updateItem() > Example
-- Update the title of the second item in a menu
local menuId = "mainMenu"
jo.menu.updateItem(menuId, 2, "title", "New Title")
-- Disable the third item
jo.menu.updateItem(menuId, 3, "disabled", true)
JO Functions > <BadgeClient /> jo.menu.updateLang() > Syntax
jo.menu.updateLang(lang)
JO Functions > <BadgeClient /> jo.menu.updateLang() > Parameters
lang : table
List of translated strings
lang.of: string - The bottom right text displaying current item number <br> default :"%1 of %2"<BadgeOptional />
lang.selection: string - The "Selection" text <br> default :"Selection"<BadgeOptional />
lang.devise: string - The devise text <br> default :"$"<BadgeOptional />
lang.number: string - The number text <br> default :"Number %1"<BadgeOptional />
lang.free: string - The "Free" text <br> default :"Free"<BadgeOptional />
lang.variation: string - The variatio, text <br> default :"Variation"<BadgeOptional />
JO Functions > <BadgeClient /> jo.menu.updateLang() > Example
-- Update menu language text
jo.menu.updateLang({
of = "%1 of %2",
selection = "Selection",
devise = "$",
number = "Number %1",
free = "Free",
variation = "Variation"
})
JO Functions > <BadgeClient /> jo.menu.updateVolume()
Set the volume level for menu sound effects <br>
JO Functions > <BadgeClient /> jo.menu.updateVolume() > Syntax
jo.menu.updateVolume(volume)
JO Functions > <BadgeClient /> jo.menu.updateVolume() > Parameters
volume : number
Volume of sound effects 0.0 to 1.0
JO Functions > <BadgeClient /> jo.menu.updateVolume() > Example
-- Set the volume level for menu sound effects
-- Volume range is 0.0 to 1.0
jo.menu.updateVolume(0.8)
JO Functions > <BadgeShared /> jo.menu.formatPrice()
A function to format a single price <br>
JO Functions > <BadgeShared /> jo.menu.formatPrice() > Syntax
jo.menu.formatPrice(price)
JO Functions > <BadgeShared /> jo.menu.formatPrice() > Parameters
price : table|integer|number
The price to format
JO Functions > <BadgeShared /> jo.menu.formatPrice() > Return Value
Type : table
The formatted price
JO Functions > <BadgeShared /> jo.menu.formatPrice() > Example
local price = 10
local formattedPrice = jo.menu.formatPrice(price)
log(formattedPrice) -- Expected output: `{money = 10}`
JO Functions > <BadgeShared /> jo.menu.formatPrices()
A function to format price variations <br>
JO Functions > <BadgeShared /> jo.menu.formatPrices() > Syntax
jo.menu.formatPrices(prices)
JO Functions > <BadgeShared /> jo.menu.formatPrices() > Parameters
prices : table|integer|number
The prices to format
JO Functions > <BadgeShared /> jo.menu.formatPrices() > Return Value
Type : table
The formatted prices
JO Functions > <BadgeShared /> jo.menu.formatPrices() > Example
local prices = {money = 10, operator = "and", gold = 20}
local formattedPrices = jo.menu.formatPrices(prices)
log(formattedPrices) -- Expected output: `{money = 10, gold = 20}`
JO Functions > <BadgeShared /> jo.menu.isPriceFree() > Syntax
jo.menu.isPriceFree(price)
JO Functions > <BadgeShared /> jo.menu.isPriceFree() > Parameters
price : table|integer|number
The price to check
JO Functions > <BadgeShared /> jo.menu.isPriceFree() > Return Value
Type : boolean
Return
trueif the price is free
JO Functions > <BadgeShared /> jo.menu.isPriceFree() > Example
local price = 10
local isFree = jo.menu.isPriceFree(price)
print(isFree) -- Expected output: `false`
price = {money = 0, bank = 0}
isFree = jo.menu.isPriceFree(price)
print(isFree) -- Expected output: `true`


<BadgeOptional />
<BadgeOptional />
<BadgeOptional />
<BadgeOptional />
<BadgeOptional />