Lua:inputQuery
Jump to navigation
Jump to search
Shows a dialog where the user can input a string.
The function returns the entered string when the user confirms the dialog. If the user cancels the dialog, nil is returned.
Function Parameters
| Parameter | Type | Description |
|---|---|---|
| caption | String | The caption of the input dialog. |
| prompt | String | The prompt text shown to the user. |
| initialstring | String | The initial text shown in the input field. |
Returns
String or nil — The entered string, or nil if the dialog was cancelled.
Examples
local result = inputQuery("Name", "Enter your name:", "")
if result ~= nil then
print("Entered name: " .. result)
else
print("Input cancelled")
end
local value = inputQuery("Health", "Enter new health value:", "100")
if value ~= nil then
local numberValue = tonumber(value)
if numberValue ~= nil then
print("New health value: " .. tostring(numberValue))
else
print("Invalid number")
end
end
local address = inputQuery("Address", "Enter an address or symbol:", "player.health")
if address ~= nil then
local resolvedAddress = getAddressSafe(address)
if resolvedAddress ~= nil then
print("Resolved address: " .. string.format("%X", resolvedAddress))
else
print("Could not resolve address")
end
end