Functions Client
Reference of all the functions and methods of the menu module. To discover the possibilities of the menu step by step, start with the Menu page.
Constructor
Client jo.menu.create()
Create a new menu. If a menu with the same ID exists, it's replaced
Add the items with MenuClass:addItem(), then send the menu to the NUI with MenuClass:send()
TIP
All the options of a menu are illustrated in Menus.
Syntax
jo.menu.create(id, data)Parameters
id : string
Unique ID of the menu
data : table
The menu configuration
data.title: string - The big title of the menu. HTML is allowed
default:"Jump On"Optional
data.subtitle: string - The subtitle of the menu, displayed above the items. HTML is allowed
default:""Optional
data.type: string - The type of menu:listortile
default:"list"Optional
data.numberOnScreen: integer -listmenu: number of items displayed before the scroll. Maximum13
default:8Optional
data.numberOnLine: integer -tilemenu: number of tiles per line
default:4Optional
data.numberLineOnScreen: integer -tilemenu: number of lines displayed before the scroll
default:6Optional
data.image: string|table - An image displayed above the items: a URL or{url, width, height, radius, style}Optional
data.displayBackButton: boolean - Display the back arrow next to the subtitle, even without history
default:falseOptional
data.hideBackground: boolean - Hide the dark background behind the menu
default:falseOptional
data.price: number|table - The price displayed when the active item has no price. See Prices Optional
data.priceTitle: string - Replace the "Price" label ofdata.priceOptional
data.distanceToClose: number - The menu closes itself when the player moves further than this distance
default:falseOptional
data.translateTitle: boolean - Usetitleas a key of the translation strings
default:falseOptional
data.translateSubtitle: boolean - Usesubtitleas a key of the translation strings
default:falseOptional
data.onBeforeEnter: function - Fired before the menu is displayed. The NUI waits for the end of the function Optional
data.onEnter: function - Fired when the menu becomes the current menu Optional
data.onBack: function - Fired when Backspace or Escape is pressed Optional
data.onExit: function - Fired when the menu is no longer the current menu Optional
data.onChange: function - Fired when the active item or a slider changes in the menu Optional
data.onTick: function - Fired every frame while the menu is the current menu Optional
Return Value
Type : MenuClass
The new menu
Example
local menu = jo.menu.create("tailor", {
title = "Tailor",
subtitle = "Clothes",
type = "list",
numberOnScreen = 12,
onEnter = function(currentData)
print("Enter the tailor")
end,
onBack = function(currentData)
jo.menu.show(false)
end,
})
menu:addItem({ title = "Hats", icon = "hats", child = "hats" })
menu:addItem({ title = "Coats", icon = "coats", child = "coats" })
menu:send()
menu:use()
jo.menu.show(true)Preview

Client jo.menu.createIfNotExist()
Create a new menu, only if no menu exists with this ID
Returns two values: the menu (the new one or the existing one) and true if the menu was created
Syntax
jo.menu.createIfNotExist(id, data)Parameters
id : string
Unique ID of the menu
data : table
The menu configuration. See jo.menu.create()
Return Value
Type : MenuClass
The menu
Example
local menu, created = jo.menu.createIfNotExist("tailor", { title = "Tailor" })
if created then
menu:addItem({ title = "Stetson" })
menu:send()
end
menu:use()
jo.menu.show(true)MenuClass Methods
Client MenuClass:addItem()
Add an item to the menu. Call MenuClass:send() to send the menu to the NUI
TIP
All the options of an item are illustrated in Items, the sliders in Sliders and the statistics in Statistics.
Syntax
MenuClass:addItem(index, item)Parameters
index : integer|table
The position of the item in the menu, or the item itself to add it at the end
item : table Optional
The item to add, when
indexis a position
item.title: string - The item label. HTML is allowed
item.subtitle: string - A second line displayed under the title Optional
item.description: string - The text displayed in the description area, under the list. HTML is allowed Optional
item.footer: string - The text displayed at the bottom of the menu. HTML is allowed Optional
item.child: string - The ID of the menu opened when the item is clicked
default:falseOptional
item.visible: boolean - Iffalse, the item is not displayed
default:trueOptional
item.disabled: boolean - Grey out the item: it can't be clicked and its sliders are hidden
default:falseOptional
item.data: table - Free storage for your own data, available in the callbacks withcurrentData.item.dataOptional
item.icon: string - The icon on the left of the item: a filename ofnui/menu/assets/images/icons(without.png) or a full image URL Optional
item.iconClass: string - CSS classes applied to the icon, likefgoldorbw. See CSS classes Optional
item.iconSize: string -"small"to reduce the size of the icon
default:"normal"Optional
item.iconRight: string - An icon displayed on the right of the item. In atilemenu, it's displayed in the bottom right corner of the tile Optional
item.prefix: string - A small icon displayed before the title Optional
item.textRight: string - A text displayed on the right of the item Optional
item.textRightClass: string - CSS classes applied totextRight, liketinyOptional
item.image: string|table - An image displayed in the description area: a URL or{url, width, height, radius, style}Optional
item.color: string|table - The CSS color of the title, or a table{title, background, accent, icon}. See Colors Optional
item.price: number|table - The price displayed under the description. See Prices
default:falseOptional
item.priceTitle: string - Replace the "Price" label above the price Optional
item.priceRight: boolean|number|table - Display a price on the right of the item:trueto displayitem.price, or a price value Optional
item.statistics: table - The list of statistics displayed in the description area. See Statistics Optional
item.sliders: table - The list of sliders of the item. See Sliders Optional
item.previewPalette: boolean - Display a square with the current color of the sliders on the right of the item
default:falseOptional
item.quantity: number - In atilemenu, a number displayed in a circle in the top right corner of the tile Optional
item.quantityCircleClass: string - CSS classes applied to the quantity circle, likefgoldOptional
item.quality: integer - In atilemenu, a quality from1to3displayed with stars Optional
item.qualityClass: string - CSS classes applied to the quality stars Optional
item.stars: table - In atilemenu, a row of stars:{current, total}Optional
item.starsClass: string - CSS classes applied to the row of stars Optional
item.tilePadding: number|string - In atilemenu, the space between the image and the edge of the tile: a number in vh, or a CSS length.0brings the image to the edge
default:1.2Optional
item.translate: boolean - Usetitleas a key of the translation strings. See jo.menu.updateLang()
default:falseOptional
item.translateDescription: boolean - Usedescriptionas a key of the translation strings
default:falseOptional
item.translateTextRight: boolean - UsetextRightas a key of the translation strings
default:falseOptional
item.bufferOnChange: boolean - Wait a few milliseconds between twoonChangeevents of fast slider moves.falsefires them on the next frame
default:trueOptional
item.onActive: function - Fired when the item becomes the active item Optional
item.onClick: function - Fired when the item is clicked or Enter is pressed Optional
item.onChange: function - Fired when a slider of the item changes Optional
item.onExit: function - Fired when the item is no longer the active item Optional
item.onTick: function - Fired every frame while the item is active Optional
Return Value
Type : MenuItemClass
The added item
Example
local menu = jo.menu.create("tailor", { title = "Tailor", subtitle = "Hats" })
-- Add an item at the end of the menu
local stetson = menu:addItem({
title = "Stetson",
icon = "hats",
description = "A wide brim hat made of felt.",
price = { money = 12.5 },
data = { hash = `HAT_STETSON` },
sliders = {
{ title = "Variation", values = { "Brown", "Black", "Grey" } },
},
onClick = function(currentData)
print("Buy", currentData.item.data.hash)
end,
})
-- Add an item at the first position
menu:addItem(1, { title = "Remove the hat" })
menu:send()Preview

Client MenuClass:deleteItem()
Delete an item of the menu and update the index of the next items. Call MenuClass:push() to send the changes to the NUI
Syntax
MenuClass:deleteItem(index)Parameters
index : integer
The index of the item to delete
Example
local menu = jo.menu.get("tailor")
menu:deleteItem(2)
menu:push()Client MenuClass:deleteValue()
Delete a property of the menu or of one of its items. Call MenuClass:push() to send the changes to the NUI {"items", index} deletes the item, like MenuClass:deleteItem()
Syntax
MenuClass:deleteValue(keys)Parameters
keys : string|table
The property name, or the path to a nested property like
{"items", 2, "price"}
Example
local menu = jo.menu.get("tailor")
-- Remove the price of the 2nd item
menu:deleteValue({ "items", 2, "price" })
menu:push()Client MenuClass:push()
Send to the NUI the changes made with updateValue(), deleteValue() and deleteItem()
TIP
See Update a menu.
Syntax
MenuClass:push()Example
local menu = jo.menu.get("tailor")
menu:updateValue("subtitle", "Hats (2)")
menu:updateValue({ "items", 1, "textRight" }, "Owned")
menu:deleteValue({ "items", 1, "price" })
-- Send the 3 changes to the NUI
menu:push()Preview

Client MenuClass:refresh()
Send the whole menu to the NUI again, without changing the active item
Use it after big changes, like items added or sorted after MenuClass:send()
If the menu is the current menu, onExit and onActive of the active item are fired again
Syntax
MenuClass:refresh()Example
local menu = jo.menu.get("tailor")
menu:addItem({ title = "Top hat", icon = "hats" })
menu:sort()
-- Send the whole menu again, the cursor stays on the same item
menu:refresh()Client MenuClass:removeItem()
DEPRECATED
since v2.4.0. Use MenuClass:deleteItem() instead
Remove an item from the menu, in Lua only
Syntax
MenuClass:removeItem(index)Parameters
index : integer
The index of the item to remove
Example
local menu = jo.menu.get("tailor")
-- Deprecated: use deleteItem() then push()
menu:deleteItem(2)
menu:push()Client MenuClass:reset()
Move the cursor of the menu back to the first item
Syntax
MenuClass:reset()Example
local menu = jo.menu.get("tailor")
menu:reset()Client MenuClass:send()
Send the menu to the NUI. Call it once the items are added
If the menu has already been sent, it's refreshed (see MenuClass:refresh())
Syntax
MenuClass:send()Example
local menu = jo.menu.create("tailor", { title = "Tailor" })
menu:addItem({ title = "Stetson" })
menu:addItem({ title = "Bowler" })
-- Send the menu once all the items are added
menu:send()Client MenuClass:setCurrentIndex()
Move the cursor to an item
Syntax
MenuClass:setCurrentIndex(index)Parameters
index : integer
The index of the item
Example
local menu = jo.menu.get("tailor")
-- Move the cursor to the 3rd item
menu:setCurrentIndex(3)Client MenuClass:sort()
Sort the items alphabetically by title
Call MenuClass:refresh() (or MenuClass:send() if the menu has never been sent) to display the new order
WARNING
sort() doesn't update the NUI: call MenuClass:refresh() after it, or MenuClass:send() if the menu has never been sent.
Syntax
MenuClass:sort(first, last)Parameters
first : integer Optional
The position of the first item to sort
default:1
last : integer Optional
The position of the last item to sort
default: the last item
Example
local menu = jo.menu.create("tailor", { title = "Tailor" })
menu:addItem({ title = "Remove the hat" })
menu:addItem({ title = "Stetson" })
menu:addItem({ title = "Bowler" })
menu:addItem({ title = "Flat cap" })
-- Sort the items from the 2nd one: "Remove the hat" stays first
menu:sort(2)
menu:send()Client MenuClass:updateItem()
DEPRECATED
since v2.3.0. Use MenuClass:updateValue() or MenuItem:updateValue() then MenuClass:push() instead
Overwrite a property of an item. The NUI is not updated
Syntax
MenuClass:updateItem(index, key, value)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
Example
local menu = jo.menu.get("tailor")
-- Deprecated: use updateValue() then push()
menu:updateValue({ "items", 2, "title" }, "Bowler hat")
menu:push()Client MenuClass:updateValue()
Update a property of the menu or of one of its items. Call MenuClass:push() to send the changes to the NUI price and priceRight values are formatted automatically
Syntax
MenuClass:updateValue(keys, value)Parameters
keys : string|table
The property name, or the path to a nested property like
{"items", 2, "title"}
value : any
The new value
Return Value
Type : boolean
Always
true
Example
local menu = jo.menu.get("tailor")
-- A property of the menu
menu:updateValue("subtitle", "Hats (2)")
-- A property of an item
menu:updateValue({ "items", 2, "disabled" }, true)
-- A nested property
menu:updateValue({ "items", 1, "sliders", 1, "current" }, 3)
menu:push()Client MenuClass:use()
Set the menu as the current menu. Same as jo.menu.setCurrentMenu()
Syntax
MenuClass:use(keepHistoric, resetMenu)Parameters
keepHistoric : boolean Optional
Keep the previous menu in the history, to go back to it with Backspace
default:true
resetMenu : boolean Optional
Move the cursor back to the first item
default:true
Example
local menu = jo.menu.get("tailor")
menu:use()
jo.menu.show(true)MenuItemClass Methods
Client MenuItemClass:deleteValue()
Delete a property of the item. Call MenuClass:push() to send the changes to the NUI
Only works on an item returned by MenuClass:addItem()
Syntax
MenuItemClass:deleteValue(keys)Parameters
keys : string|table
The property name, or the path to a nested property like
{"sliders", 2}
Example
local menu = jo.menu.create("tailor", { title = "Tailor" })
local stetson = menu:addItem({ title = "Stetson", price = { money = 12.5 } })
menu:send()
-- Later
stetson:deleteValue("price")
menu:push()Client MenuItemClass:getParentMenu()
Get the menu the item belongs to
Only works on an item returned by MenuClass:addItem()
Syntax
MenuItemClass:getParentMenu()Return Value
Type : MenuClass
The parent menu
Example
local menu = jo.menu.create("tailor", { title = "Tailor" })
local stetson = menu:addItem({ title = "Stetson" })
local parent = stetson:getParentMenu()
print(parent.id) -- "tailor"Client MenuItemClass:updateValue()
Update a property of the item. Call MenuClass:push() to send the changes to the NUI
Only works on an item returned by MenuClass:addItem()
Syntax
MenuItemClass:updateValue(keys, value)Parameters
keys : string|table
The property name, or the path to a nested property like
{"sliders", 1, "current"}
value : any
The new value
Example
local menu = jo.menu.create("tailor", { title = "Tailor" })
local stetson = menu:addItem({ title = "Stetson", price = { money = 12.5 } })
menu:send()
-- Later, the player bought the hat
stetson:updateValue("textRight", "Owned")
stetson:updateValue("iconRight", "tick")
menu:push()Preview

Menu Management
Client jo.menu.addItem()
Add an item to a menu from its ID. Same as MenuClass:addItem()
Syntax
jo.menu.addItem(id, p, item)Parameters
id : string
The menu ID
p : integer|table
The position of the item in the menu, or the item itself to add it at the end
item : table Optional
The item to add, when
pis a position. See MenuClass:addItem() for the keys
Example
jo.menu.create("tailor", { title = "Tailor" })
jo.menu.addItem("tailor", { title = "Stetson", icon = "hats" })
jo.menu.addItem("tailor", 1, { title = "Remove the hat" })
jo.menu.send("tailor")Client jo.menu.delete()
Delete a menu, in Lua and in the NUI
Syntax
jo.menu.delete(id)Parameters
id : string
The menu ID
Example
jo.menu.delete("tailor")
print(jo.menu.isExist("tailor")) -- falseClient jo.menu.get()
Get a menu from its ID
Syntax
jo.menu.get(id)Parameters
id : string
The menu ID
Return Value
Type : MenuClass
The menu object
Example
local menu = jo.menu.get("tailor")
menu:updateValue("subtitle", "Hats")
menu:push()Client jo.menu.isExist()
Check if a menu exists
Syntax
jo.menu.isExist(id)Parameters
id : string
The menu ID
Return Value
Type : boolean
Returns
trueif the menu exists
Example
if not jo.menu.isExist("tailor") then
createTailorMenu()
endClient jo.menu.refresh()
Refresh a menu from its ID. Same as MenuClass:refresh()
Syntax
jo.menu.refresh(id)Parameters
id : string
The menu ID
Example
jo.menu.addItem("tailor", { title = "Top hat" })
jo.menu.refresh("tailor")Client jo.menu.reset()
Reset a menu from its ID. Same as MenuClass:reset()
Syntax
jo.menu.reset(id)Parameters
id : string
The menu ID
Example
jo.menu.reset("tailor")Client jo.menu.send()
Send a menu to the NUI from its ID. Same as MenuClass:send()
Syntax
jo.menu.send(id)Parameters
id : string
The menu ID
Example
jo.menu.create("tailor", { title = "Tailor" })
jo.menu.addItem("tailor", { title = "Stetson" })
jo.menu.send("tailor")Client jo.menu.set()
Replace the menu stored with this ID
Syntax
jo.menu.set(id, menu)Parameters
id : string
The menu ID
menu : MenuClass
The menu
Example
local menu = jo.menu.get("tailor")
jo.menu.set("tailor_copy", menu)Client jo.menu.sort()
Sort the items of a menu from its ID. Same as MenuClass:sort()
Syntax
jo.menu.sort(id, first, last)Parameters
id : string
The menu ID
first : integer Optional
The position of the first item to sort
default:1
last : integer Optional
The position of the last item to sort
default: the last item
Example
jo.menu.sort("tailor")
jo.menu.refresh("tailor")Client jo.menu.updateItem()
DEPRECATED
since v2.3.0. Use MenuClass:updateValue() or MenuItem:updateValue() then MenuClass:push() instead
Overwrite a property of an item from the menu ID. The NUI is not updated
Syntax
jo.menu.updateItem(id, index, key, value)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
Example
-- Deprecated: use updateValue() then push()
local menu = jo.menu.get("tailor")
menu:updateValue({ "items", 2, "title" }, "Bowler hat")
menu:push()Display
Client jo.menu.displayLoader()
Display a loading animation in the menu
Syntax
jo.menu.displayLoader(value)Parameters
value : boolean Optional
falseto hide the loader
default:true
Example
jo.menu.displayLoader()
local outfits = jo.callback.triggerServer("myResource:getOutfits")
-- build the menu with the outfits...
jo.menu.hideLoader()Preview

Client jo.menu.forceBack()
Go back to the previous menu of the history, like Backspace
Syntax
jo.menu.forceBack()Example
menu:addItem({
title = "Validate",
onClick = function()
-- save the choice, then go back to the previous menu
jo.menu.forceBack()
end,
})Client jo.menu.hideLoader()
Hide the loading animation
Syntax
jo.menu.hideLoader()Example
jo.menu.displayLoader()
Wait(1000)
jo.menu.hideLoader()Client jo.menu.isOpen()
Check if the menu is displayed
Syntax
jo.menu.isOpen()Return Value
Type : boolean
Returns
trueif the menu is displayed
Example
RegisterCommand("tailor", function()
if jo.menu.isOpen() then return end
jo.menu.setCurrentMenu("tailor")
jo.menu.show(true)
end)Client jo.menu.isSoftHidden()
Check if the menu is hidden by jo.menu.softHide()
Syntax
jo.menu.isSoftHidden()Return Value
Type : boolean
Returns
trueduring the execution of thejo.menu.softHide()function
Example
CreateThread(function()
while jo.menu.isOpen() do
if not jo.menu.isSoftHidden() then
-- draw something only when the menu is visible
end
Wait(0)
end
end)Client jo.menu.setCurrentMenu()
Set the current menu: the one displayed by jo.menu.show()
If the menu doesn't exist, the handler registered with jo.menu.missingMenuHandler() is called
Syntax
jo.menu.setCurrentMenu(id, keepHistoric, resetMenu)Parameters
id : string
The menu ID
keepHistoric : boolean Optional
Keep the previous menu in the history, to go back to it with Backspace
default:true
resetMenu : boolean Optional
Move the cursor back to the first item
default:true
Example
-- Open the menu, with the cursor on the first item
jo.menu.setCurrentMenu("tailor")
jo.menu.show(true)
-- Open a menu without history: Backspace won't go back to "tailor"
jo.menu.setCurrentMenu("hats", false)
-- Go back to a menu without moving its cursor
jo.menu.setCurrentMenu("tailor", true, false)Preview

Client jo.menu.show()
Show or hide the current menu
While the menu is displayed, the radar is hidden and the weapon wheel and pause menu controls are disabled
WARNING
The first menu doesn't close itself with Backspace: hide it in its onBack callback. See Go back.
Syntax
jo.menu.show(show, keepInput, hideRadar, playMenuAnimation, hideCursor)Parameters
show : boolean
trueto show the menu,falseto hide it
keepInput : boolean Optional
Keep the game controls active, to move the player while the menu is open
default:true
hideRadar : boolean Optional
Unused: the radar is always hidden while the menu is displayed
default:true
playMenuAnimation : boolean Optional
Play the open/close animation
default:true
hideCursor : boolean Optional
Hide the mouse cursor
default:false
Example
-- Show the menu, the player can move
jo.menu.show(true)
-- Show the menu and block the game controls
jo.menu.show(true, false)
-- Hide the menu
jo.menu.show(false)Client jo.menu.softHide()
Hide the menu during the execution of a function, then display it again
The function is executed synchronously: jo.menu.softHide() returns once the menu is displayed again
Syntax
jo.menu.softHide(cb, playMenuAnimation, keepBackground)Parameters
cb : function
The function executed while the menu is hidden
playMenuAnimation : boolean Optional
Play the open/close animation
default:true
keepBackground : boolean Optional
Keep the dark background of the menu while it's hidden
default:false
Example
menu:addItem({
title = "Try on",
onClick = function()
-- Hide the menu 3 seconds, keep its background
jo.menu.softHide(function()
Wait(3000)
end, true, true)
end,
})Preview

Current State
Client jo.menu.doesActiveButtonChange()
Check if the active item (or the menu) changed during the last update
Useful in onChange callbacks, to know if a slider moved or if the cursor moved
Syntax
jo.menu.doesActiveButtonChange()Return Value
Type : boolean
Returns
trueif the active item changed
Example
menu:addItem({
title = "Stetson",
sliders = { { title = "Variation", values = { 1, 2, 3 } } },
onChange = function(currentData)
if jo.menu.doesActiveButtonChange() then return end
print("The slider moved to", currentData.item.sliders[1].value)
end,
})Client jo.menu.getCurrentData()
Get the current state of the menu: the data passed to all the callbacks
Syntax
jo.menu.getCurrentData()Return Value
Type : table
{menu = menuID, index = activeItemIndex, item = activeItem}
Example
local data = jo.menu.getCurrentData()
print(data.menu, data.index, data.item.title)Client jo.menu.getCurrentIndex()
Get the index of the active item of the current menu
Syntax
jo.menu.getCurrentIndex()Return Value
Type : integer
The index of the active item
Example
local index = jo.menu.getCurrentIndex()
print("The active item is the item", index)Client jo.menu.getCurrentItem()
Get the active item of the current menu
Syntax
jo.menu.getCurrentItem()Return Value
Type : MenuItemClass
The active item
Example
local item = jo.menu.getCurrentItem()
print(item.title)Client jo.menu.getCurrentMenu()
Get the current menu
Syntax
jo.menu.getCurrentMenu()Return Value
Type : MenuClass
The current menu
Example
local menu = jo.menu.getCurrentMenu()
print(menu.title)Client jo.menu.getCurrentMenuId()
Get the ID of the current menu
Syntax
jo.menu.getCurrentMenuId()Return Value
Type : string
The ID of the current menu
Example
if jo.menu.getCurrentMenuId() == "tailor" then
print("The player is in the tailor menu")
endClient jo.menu.getPreviousData()
Get the state of the menu before the last change
Syntax
jo.menu.getPreviousData()Return Value
Type : table
{menu = menuID, index = activeItemIndex, item = activeItem}
Example
menu:addItem({
title = "Stetson",
onActive = function(currentData)
local previous = jo.menu.getPreviousData()
print("Previous item:", previous.item and previous.item.title)
end,
})Client jo.menu.isCurrentMenu()
Check if a menu is the current menu and is displayed
Syntax
jo.menu.isCurrentMenu(id)Parameters
id : string
The menu ID
Return Value
Type : boolean
Returns
trueif the menu is displayed and is the current one
Example
if jo.menu.isCurrentMenu("tailor") then
jo.menu.get("tailor"):refresh()
endEvents
Client jo.menu.fireAllLevelsEvent()
Fire an event on the current menu, then on its active item
Syntax
jo.menu.fireAllLevelsEvent(eventName, ...)Parameters
eventName : string
The name of the event, like
onTick
... : any Optional
Additional arguments for the listeners
Example
-- Fire the onTick of the current menu and of its active item
jo.menu.fireAllLevelsEvent("onTick")Client jo.menu.fireEvent()
Fire an event of a menu or an item
The listeners receive the current data (see jo.menu.getCurrentData()) followed by the additional arguments
The client and server events defined with <eventName>ClientEvent and <eventName>ServerEvent keys are triggered too
TIP
Syntax
jo.menu.fireEvent(item, eventName, ...)Parameters
item : table
The menu or the item
eventName : string
The name of the event, like
onClick
... : any Optional
Additional arguments for the listeners
Example
-- Fire the onActive callback of the active item again
jo.menu.fireEvent(jo.menu.getCurrentItem(), "onActive")
-- With additional arguments
jo.menu.fireEvent(jo.menu.getCurrentMenu(), "onRefresh", "myArgument")Client jo.menu.missingMenuHandler()
Register a function to create a menu the first time it's needed
Called when jo.menu.setCurrentMenu() or an item child targets this menu ID and the menu doesn't exist
Syntax
jo.menu.missingMenuHandler(id, callback)Parameters
id : string
The menu ID
callback : function
The function that creates the menu
Example
-- The "hats" menu is created the first time it's opened
jo.menu.missingMenuHandler("hats", function()
local hats = jo.menu.create("hats", { title = "Tailor", subtitle = "Hats" })
hats:addItem({ title = "Stetson" })
hats:send()
hats:use(true)
end)
local menu = jo.menu.create("tailor", { title = "Tailor" })
menu:addItem({ title = "Hats", child = "hats" })
menu:send()Client jo.menu.onChange()
Listen to all the changes of all the menus: active item, sliders, menu
The callback receives {menu, index, item}. It's unregistered when the resource stops
Syntax
jo.menu.onChange(cb)Parameters
cb : function
The function fired on each change
Example
jo.menu.onChange(function(data)
print(("Menu %s, item %d: %s"):format(data.menu, data.index, data.item.title))
end)Client jo.menu.runRefreshEvents()
Fire the events of the current menu again, as if it was just opened
Syntax
jo.menu.runRefreshEvents(menuEvent, itemEvent)Parameters
menuEvent : boolean Optional
Fire
onExitandonEnterof the menu, andonExitandonActiveof the item
default:false
itemEvent : boolean Optional
Fire
onExitandonActiveof the active item
default:false
Example
-- Fire onExit and onActive of the active item again
jo.menu.runRefreshEvents(false, true)Settings
Client jo.menu.playAudio()
Play a sound of the menu
Syntax
jo.menu.playAudio(sound)Parameters
sound : string
The sound name:
button,coins,menu_open,menu_closeorselected
Example
menu:addItem({
title = "Buy",
onClick = function()
jo.menu.playAudio("coins")
end,
})Client jo.menu.updateLang()
Translate the texts of the menu
You can also add your own keys, used by the translate* options of the menus, items and sliders
TIP
You can add your own keys and use them with the translate* options. See Translations.
Syntax
jo.menu.updateLang(lang)Parameters
lang : table
The translated strings, by key
lang.of: string - The counter of the items and sliders.%1is the current position,%2the total
default:"%1 of %2"Optional
lang.price: string - The label above the price
default:"Price"Optional
lang.devise: string - The currency symbol
default:"$"Optional
lang.free: string - The text displayed when the price is0
default:"Free"Optional
lang.number: string - The title of an item without title.%1is the item position
default:"Number %1"Optional
Example
jo.menu.updateLang({
of = "%1 sur %2",
price = "Prix",
devise = "€",
free = "Gratuit",
number = "Numéro %1",
})Preview

Client jo.menu.updateVolume()
Set the volume of the menu sounds
Syntax
jo.menu.updateVolume(volume)Parameters
volume : number
The volume, from
0.0to1.0
default:0.5
Example
jo.menu.updateVolume(0.2)