Exports
Exports - Client
addPoint
- Creates a static 3D interactable prompt.
exports.lunar_bridge:addPoint({
coords = coords, -- vector3
distance = 1.0, -- the distance at which the becomes interactable
options = {
{
label = 'Open door',
icon = 'door-open',
onSelect = function(data)
print('opened door')
print('args: ' .. data)
end,
args = 6 -- you can define extra args
},
{
label = 'Go into garage',
icon = 'warehouse',
onSelect = function()
print('went into garage')
end,
canInteract = function()
return true -- You can add your own condition here
end
},
}
})
addLocalEntity
- Attaches a 3D interactable prompt to a local entity.
exports.lunar_bridge:addLocalEntity({
entity = entity, -- number
distance = 1.0, -- the distance at which the becomes interactable
offset = vector3(0.0, 0.0, 0.0),
options = {
{
label = 'Open door',
icon = 'door-open',
onSelect = function(data)
print('opened door')
print('args: ' .. data)
end,
args = 6 -- you can define extra args
},
{
label = 'Go into garage',
icon = 'warehouse',
onSelect = function()
print('went into garage')
end,
canInteract = function()
return true -- You can add your own condition here
end
},
}
})
openPedInteractionMenu
- Opens conversation style menu.
exports.lunar_bridge:openPedInteractionMenu(
ped,
{ name = "Mike", specifier = "General Store Clerk" },
{
question = "Welcome to Mike's General Store! How can I help you today?",
answers = {
-- if there's a pos_ or neg_ prefix then it colors the option otherwise it's neutral
-- you can add as many options as you wish
{ id = "pos_buy", label = "I'd like to buy something", icon = "basket-shopping" },
{ id = "neg_leave", label = "Just looking around", icon = "eye" }
}
-- Could alternatively use:
-- answerItems = { { name = "item1", label = "Item 1", imageUrl = "url.png" }, ... }
-- answerNumberInput = "Enter amount"
},
-- THE CALLBACK FUNCTION - THIS IS THE CORE OF THE CONVERSATION SYSTEM
-- It receives the player's response data and returns the next question or nil
-- This is what controls the entire conversation flow and branching logic
function(answer)
-- IMPORTANT: The conversation ends immediately when the callback returns nil
-- This happens when player chooses to leave or if ESCAPE is pressed
if not answer or answer.id == "leave" or answer.id == "cancel" then
-- Returning nil terminates the conversation
return nil
end
-- Player wants to buy something - return a new question object with items
-- The callback uses the answer.id to determine which branch to take
if answer.id == "buy" then
return {
question = "What would you like to purchase?",
answerItems = {
{ name = "bread", label = "Fresh Bread", imageUrl = "nui://ox_inventory/web/images/bread.png" },
{ name = "milk", label = "Milk", imageUrl = "nui://ox_inventory/web/images/milk.png" },
{ name = "apple", label = "Apples", imageUrl = "nui://ox_inventory/web/images/apple.png" }
}
}
end
-- Player selected an item to purchase
-- The callback receives answer.itemName when the player selects an item
if answer.itemName then
-- Return a question that asks for a number input
return {
question = "How many would you like to purchase?",
answerNumberInput = "Enter amount"
}
end
-- Player entered a quantity
-- The callback receives answer.value when player inputs a number
if answer.value then
local quantity = answer.value
local totalPrice = quantity * 5 -- Example price calculation
-- Continue the conversation with a confirmation question
return {
question = "That will be $" .. totalPrice .. ". Would you like to complete your purchase?",
answers = {
{ id = "pos_confirm", label = "Yes, I'll buy it", icon = "check" },
{ id = "pos_cancel", label = "No, that's too expensive", icon = "xmark" }
}
}
end
-- Player confirmed purchase
if answer.id == "confirm" then
-- IMPORTANT: Returning nil ends conversation
return nil
end
-- Fallback: If none of the expected conditions are met
-- End the conversation by returning nil
return nil
end
)
Last updated