Page 1 of 1

The value of HUD Text -> Body Text in the active node of the active quest through the script

Posted: Sun May 29, 2022 12:59 pm
by EVG
Is it possible to get the value of HUD Text -> Body Text in the active node of the active quest through a script?
How.png
How.png (54.68 KiB) Viewed 832 times

Re: The value of HUD Text -> Body Text in the active node of the active quest through the script

Posted: Sun May 29, 2022 1:20 pm
by Tony Li
Hi,

It's possible for more than one node to be active at a time. For example, if the quest asks the player to collect 3 apples or 5 strawberries, the apples and strawberries nodes would both the active at the same time.

To get a list containing all of the active HUD content, use Quest.GetContentList():

Code: Select all

QuestJournal journal = QuestMachine.GetQuestJournal();
Quest quest = journal.FindQuest("Your Quest ID");
List<QuestContent> hudContent = quest.GetContentList(QuestContentCategory.HUD);
Then you can loop through the list to get just the body text:

Code: Select all

foreach (QuestContent content in hudContent)
{
    if (content is BodyTextQuestContent)
    {
        Debug.Log("Body Text: " + content.runtimeText);
    }
}

Re: The value of HUD Text -> Body Text in the active node of the active quest through the script

Posted: Sun May 29, 2022 1:38 pm
by EVG
Thanks, very helpful!

Re: The value of HUD Text -> Body Text in the active node of the active quest through the script

Posted: Sun May 29, 2022 1:57 pm
by Tony Li
Happy to help!