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

Announcements, support questions, and discussion for Quest Machine.
Post Reply
EVG
Posts: 27
Joined: Sun Jul 04, 2021 4:55 pm

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

Post 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 831 times
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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);
    }
}
EVG
Posts: 27
Joined: Sun Jul 04, 2021 4:55 pm

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

Post by EVG »

Thanks, very helpful!
Post Reply