Prompt Client
A library to manage prompts in the game.
TIP
The list of the input HashName for keys is available in the rdr3 discoveries github
JO Functions
jo.prompt.create()
A function to create a new prompt.
Syntax
jo.prompt.create(group, str, key, holdTime, page)
Parameters
group
: string
The name of the group. Use "interaction" to display the prompt without need to call jo.prompt.displayGroup every frame
str
: string
The label of the key
key
: string|table
Input (string or list of strings)
The input of the key
holdTime
: integer Optional
Duration to complete the prompt in ms
Usefalse
for classic prompt without holding timer
default: false
page
: integer Optional
The page of the prompt
default: 0
Return Value
Type : integer
The prompt ID
Example
local group = "interaction"
local keyLabel = "The key"
local key = "INPUT_JUMP"
local duration = 1000
jo.prompt.create(group, keyLabel, key, duration)
jo.prompt.delete()
A function to delete a prompt.
Syntax
jo.prompt.delete(group, key, page)
Parameters
group
: string
The name of the group
key
: string
The input of the key
page
: integer Optional
The page of the prompt
default: current page
Example
local group = "interaction"
local key = "INPUT_JUMP"
jo.prompt.deletePrompt(group, key)
jo.prompt.deleteAllGroups()
A function to delete all prompts created
Syntax
jo.prompt.deleteAllGroups()
Example
local group = "interaction"
local keyLabel = "The key"
local key = "INPUT_JUMP"
local duration = 1000
jo.prompt.create(group, keyLabel, key, duration)
jo.prompt.deleteAllGroups()
print(jo.prompt.isGroupExist('interaction'))
-- Expected output : false
jo.prompt.deleteGroup()
A function to delete a group and all its prompts.
Syntax
jo.prompt.deleteGroup(group)
Parameters
group
: string
The name of the group
Example
local group = "shop"
jo.prompt.deleteGroup(group)
jo.prompt.displayGroup()
A function to display a prompt group during this frame.
Needs to be called each frame.
Syntax
jo.prompt.displayGroup(group, title)
Parameters
group
: string
The name of the prompt group to display this frame
title
: string
The title to display for this prompt group
Example
CreateThread(function()
local group = "shop"
local title = "Stable shop"
local keyLabel = "The key"
local key = "INPUT_JUMP"
jo.prompt.create(group, keyLabel, key)
while true do
jo.prompt.displayGroup(group, title)
Wait(0)
end
end)
jo.prompt.doesLastCompletedIs()
A function that returns if it's the last prompt completed.
Syntax
jo.prompt.doesLastCompletedIs(group, key, page)
Parameters
group
: string
The name of the group
key
: string
The input of the key
page
: integer Optional
The page of the prompt
default: current page
Return Value
Type : boolean
Return
true
if key is the last input completed
Example
local group = "shop"
local key = "INPUT_ENTER"
print(jo.prompt.doesLastCompletedIs(group, key))
jo.prompt.editKeyLabel()
A function to edit the label of a key.
Syntax
jo.prompt.editKeyLabel(group, key, label, page)
Parameters
group
: string
The name of the group
key
: string
The input of the key
label
: string
The label of the key
page
: integer Optional
The page of the prompt
default: current page
Example
local group = "shop"
local key = "INPUT_JUMP"
local label = "The new label"
jo.prompt.editKeyLabel(group, key, label)
jo.prompt.get()
A function to get the prompt ID.
Syntax
jo.prompt.get(group, key, page)
Parameters
group
: string
The name of the group
key
: string
The input of the key
page
: integer Optional
The page of the prompt
default: current page
Return Value
Type : integer|boolean
The prompt ID or
false
Example
local group = "shop"
local key = "INPUT_JUMP"
print(jo.prompt.get(group, key))
jo.prompt.getAll()
A function to get all registered prompts.
Syntax
jo.prompt.getAll()
Return Value
Type : table
All prompt registered
Example
local groups = jo.prompt.getAll
log(groups)
jo.prompt.getGroup()
A function to get the group ID.
Syntax
jo.prompt.getGroup(group)
Parameters
group
: string
The name of the group
Return Value
Type : integer|boolean
The group ID or
false
Example
local groupName = "MyGroup"
local group = jo.prompt.getGroup(groupName)
log(group)
jo.prompt.getPage()
A function to get the current page ID for a group.
Syntax
jo.prompt.getPage(group)
Parameters
group
: string
The name of the group
Return Value
Type : integer
The page ID
Example
local groupName = "MyGroup"
local page = jo.prompt.getPage(groupName)
log(page)
jo.prompt.getProgress()
A function to return the progress of a prompt.
Syntax
jo.prompt.getProgress(group, key, page)
Parameters
group
: string
The name of the group
key
: string
The input of the key
page
: integer Optional
The page of the prompt
default: current page
Return Value
Type : number
Return the percent of the prompt progress
Example
local group = "interaction"
local keyLabel = "The key"
local key = "INPUT_JUMP"
jo.prompt.create(group, keyLabel, key)
CreateThread(function()
while true do
print(jo.prompt.getProgress(group, key))
Wait(0)
end
end)
jo.prompt.isActive()
A function to know if a prompt is active or not.
Syntax
jo.prompt.isActive(group, key, page)
Parameters
group
: string
The name of the group
key
: string
The input of the key
page
: integer Optional
The page of the prompt
default: current page
Return Value
Type : boolean
Return
true
if the prompt is active
Example
local group = "interaction"
local keyLabel = "The key"
jo.prompt.isActive(group, key)
-- Expected output : false
jo.prompt.isCompleted()
A function to test if the prompt is pressed and completed.
Syntax
jo.prompt.isCompleted(group, key, fireMultipleTimes, page)
Parameters
group
: string
The name of the group
key
: string
The input of the key
fireMultipleTimes
: boolean Optional
Fire true if the prompt is completed and until another prompt is completed
default: false
page
: integer Optional
The page of the prompt
default: current page
Return Value
Type : boolean
Return
true
if the key is pressed and completed
Example
CreateThread(function()
local group = "interaction"
local keyLabel = "The key"
local key = "INPUT_JUMP"
local duration = 1000
jo.prompt.create(group, keyLabel, key, duration)
while true do
if jo.prompt.isCompleted(group, key) then
print('Key completed !')
end
jo.prompt.displayGroup(group, title)
Wait(0)
end
end)
jo.prompt.isEnabled()
A function to know if the prompt is enabled.
Syntax
jo.prompt.isEnabled(group, key, page)
Parameters
group
: string
The name of the group
key
: string
The input of the key
page
: integer Optional
The page of the prompt
default: current page
Return Value
Type : boolean
Return
true
if the prompt is enabled
Example
local group = "interaction"
local keyLabel = "The key"
jo.prompt.isEnabled(group, key)
-- Expected output : false
jo.prompt.isExist()
A function to know if a prompt exists.
Syntax
jo.prompt.isExist(group, key, page)
Parameters
group
: string
The name of the group
key
: string
The input of the key
page
: integer Optional
The page of the prompt
default: current page
Return Value
Type : boolean
Return
true
if the prompt exists
Example
local group = "interaction"
local keyLabel = "The key"
local key = "INPUT_JUMP"
jo.prompt.create(group, keyLabel, key)
print(jo.prompt.isPromptExist('interaction', 'INPUT_JUMP'))
-- Expected output : true
print(jo.prompt.isGroupExist('new_group', 'INPUT_RELOAD'))
-- Expected output : false
jo.prompt.isGroupExist()
A function to know if a prompt group exists.
Syntax
jo.prompt.isGroupExist(group)
Parameters
group
: string
The name of the group
Return Value
Type : boolean
Return
true
if the group exists
Example
local group = "interaction"
local keyLabel = "The key"
local key = "INPUT_JUMP"
jo.prompt.create(group, keyLabel, key)
print(jo.prompt.isGroupExist('interaction'))
-- Expected output : true
print(jo.prompt.isGroupExist('new_group'))
-- Expected output : false
jo.prompt.isPressed()
A function to know if a key is pressed.
Syntax
jo.prompt.isPressed(key)
Parameters
key
: string
The input of the key
Return Value
Type : boolean
Return
true
if the key is pressed
Example
local key = "INPUT_FRONTEND_ACCEPT"
print(jo.prompt.isPressed(key))
jo.prompt.isVisible()
A function to check if a prompt is visible.
Syntax
jo.prompt.isVisible(group, key, page)
Parameters
group
: string
The name of the group
key
: string
The input of the key
page
: integer Optional
The page of the prompt
default: current page
Return Value
Type : boolean
Return
true
if the prompt is visible
Example
local group = "shop"
local key = "INPUT_JUMP"
local isVisible = jo.prompt.isVisible(group, key)
log(isVisible)
jo.prompt.setEnabled()
A function to define if the prompt is enabled or not.
Syntax
jo.prompt.setEnabled(group, key, value, page)
Parameters
group
: string
The name of the group
key
: string
The input of the key
value
: boolean
If the prompt is enabled or not
page
: integer Optional
The page of the prompt
default: current page
Example
local group = "shop"
local key = "INPUT_JUMP"
jo.prompt.setEnabled(group, key, false)
jo.prompt.setGroups()
A function to overwrite the prompt groups value.
Syntax
jo.prompt.setGroups(groups)
Parameters
groups
: table
The prompt group value from other script get with jo.prompt.getAll()
Example
local groups = exports.resourceName:getPrompt()
jo.prompt.setGroups(groups)
jo.prompt.setVisible()
Turn on/off a prompt.
Syntax
jo.prompt.setVisible(group, key, value, page)
Parameters
group
: string
The name of the group
key
: string
The input of the key
value
: boolean
If the prompt is visible or not
page
: integer Optional
The page of the prompt
default: current page
Example
local group = "shop"
local key = "INPUT_JUMP"
local isVisible = false
jo.prompt.setVisible(group, key, isVisible)
jo.prompt.waitRelease()
A function to wait for the release of pressed key.
Syntax
jo.prompt.waitRelease(key)
Parameters
key
: string
The input of the key
Example
CreateThread(function()
local group = "interaction"
local keyLabel = "The key"
local key = "INPUT_JUMP"
local duration = 1000
jo.prompt.create(group, keyLabel, key, duration)
while true do
if jo.prompt.isCompleted(group, key) then
print('Key completed !')
jo.prompt.waitRelease(key)
print('Key released !')
end
jo.prompt.displayGroup(group, title)
Wait(0)
end
end)