How to access new field in Quest Entry (via Code)

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Saper
Posts: 52
Joined: Tue Jan 12, 2021 11:25 am

How to access new field in Quest Entry (via Code)

Post by Saper »

Hi Tony

I have a question, how to access "New Field" added to quest entry:
Dialogue_1.png
Dialogue_1.png (8.22 KiB) Viewed 1025 times
Dialogue_2.png
Dialogue_2.png (8.63 KiB) Viewed 1025 times
Dialogue_3.png
Dialogue_3.png (7.09 KiB) Viewed 1025 times
I would like to access this second field, how i can do it?
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to access new field in Quest Entry (via Code)

Post by Tony Li »

Hi,

You have a duplicate field. Expand All Fields, and delete the second "Entry 3" field:

duplicateFields.png
duplicateFields.png (61.03 KiB) Viewed 1017 times

When you add a new entry field, enter some text to append to the end of the field name. For example, to create a field named "Entry 3 Reward", set the text entry area to "Reward" before clicking Create:

addNewField.png
addNewField.png (12.52 KiB) Viewed 1017 times

To access this field in C#, use DialogueLua.GetQuestField(). Example:

Code: Select all

string reward = DialogueLua.GetQuestField("Thief Quest", "Entry 3 Reward").asString;
Saper
Posts: 52
Joined: Tue Jan 12, 2021 11:25 am

Re: How to access new field in Quest Entry (via Code)

Post by Saper »

Thanks for answer, it will help a lot

I understand that with help of SetQuestField() I can change field value via code. Where i can check what variables is accepted by what field type?
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to access new field in Quest Entry (via Code)

Post by Tony Li »

Lua is a dynamically typed language. You can assign any type of value to any variable or field. So you can do this, even though it might not make sense:

Code: Select all

DialogueLua.SetQuestField("Kill Rats", "XP Reward", 50); // Set the XP Reward field to the number 50.
DialogueLua.SetQuestField("Kill Rats", "XP Reward", "Internet Exposure"); // Set the XP Reward field to the string "Internet Exposure".
Saper
Posts: 52
Joined: Tue Jan 12, 2021 11:25 am

Re: How to access new field in Quest Entry (via Code)

Post by Saper »

Hi Tony

One more question, Let's say quest was changed from Timeline or Dialogue Trigger is there a some kinda event telling unity that this quest was changed to another state?
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to access new field in Quest Entry (via Code)

Post by Tony Li »

Post Reply