API:InteractGetBaseInteractionData
From RoR Wiki
UI Lua API · Interact functions
Version: WAR 1.4.8
Returns the main menu of the NPC or object the player is interacting with: its name, greeting text, interaction options and quests.
menuData = InteractGetBaseInteractionData(interactionId)
Arguments
- interactionId
number– Id of the current interaction, as passed to handlers ofSystemData.Events.INTERACT_DEFAULT. Only its low 16 bits are compared.
Returns
- menuData
table– The menu, or nothing ifinteractionIddoes not match the current interaction.
| Key | Type | Meaning |
|---|---|---|
name |
wstring |
Name of the interaction target. |
text |
wstring |
Greeting text. |
options |
table |
Array of option tables (see below). |
quests |
table |
Array of quest tables (see below). |
Each table in options:
| Key | Type | Meaning |
|---|---|---|
type |
number |
Interaction type, compared by the stock UI with GameData.InteractType values. Pass it to InteractSelect.
|
trainType |
number |
Only on options with type 0: the trainer type, one of 1, 2, 4, 8 or 16. The stock UI compares it with GameData.InteractTrainerType values.
|
Each table in quests:
| Key | Type | Meaning |
|---|---|---|
name |
wstring |
Quest name. |
type |
number |
Always 6. Pass it to InteractSelect.
|
icon |
number |
– |
completion |
number |
Quest state; the stock UI compares it with GameData.QuestCompletion.OFFER, REPEATABLE_OFFER and PENDING.
|
slot |
number |
Position of the quest in the list, starting at 0. Pass it as the third argument of InteractSelect. |
Details
- The options list is built from the target's interaction flags, types 0 to 23. Type 6 never appears in
options; quests are listed inquestsinstead. - A trainer can offer several trainer types. Each one gets its own option with
type0 and a differenttrainType. - The stock UI treats a
nilresult as "nothing to show" and closes the window. - The function needs at least one argument and only reads the last one.
Errors
None besides the generic Invalid Parameters message when the argument is missing or not a number.
Example
From default/ea_interactionwindow/source/interactionbase.lua:
local menuData = InteractGetBaseInteractionData( interactionTargetID )
if (menuData == nil)
then
EA_Window_InteractionBase.Done()
return
else
LabelSetText( "EA_Window_InteractionBaseTargetName", menuData.name )
LabelSetText( "EA_Window_InteractionBaseText", menuData.text )
EA_Window_InteractionBase.optionListData = menuData.options
EA_Window_InteractionBase.questListData = menuData.quests
end
