Page 1 of 1

Error in updating Quest fileds through code at runtime

Posted: Thu Jan 27, 2022 7:25 am
by molasses
Hi, I write a QuestManager script to manage quests, and want to synchronize the quest data between script and Dialogue Database. When the quest conversation start, I use code below to change the quest field in database:

Code: Select all

public void OnQuestAccepted(int index)
    {
        DialogueLua.SetQuestField("DOG HELP Quest", "questcode", AllQuests[index].hashcode);
        if (!string.IsNullOrEmpty(AllQuests[index].target1))
        {
            DialogueLua.SetQuestField("DOG HELP Quest", "target1", AllQuests[index].target1);
            DialogueLua.SetQuestField("DOG HELP Quest", "target1num", AllQuests[index].targetNum1);
        }
        if (!string.IsNullOrEmpty(AllQuests[index].target2))
        {
            DialogueLua.SetQuestField("DOG HELP Quest", "target2", AllQuests[index].target2);
            DialogueLua.SetQuestField("DOG HELP Quest", "target2num", AllQuests[index].targetNum2);
        }
    }
And when the quest is accepted, I use this method to change quest states in script:

Code: Select all

private void SetQuestStateInCode(double hashcode, double state)
    {
        AllQuests[(int)hashcode].questState = (int)state;
    }
However, I found that the quest field "questcode", "target1" , "target1num" did'nt change, Where is the problem?

Re: Error in updating Quest fileds through code at runtime

Posted: Thu Jan 27, 2022 9:50 am
by Tony Li
Hi,

The Dialogue Editor doesn't show runtime values (except for the Watches tab). It shows the original values in the database.

Are you sure your OnQuestAccepted() method is running?

If so, are you sure the strings are non-empty and they are calling DialogueLua.SetQuestField()?

If so, then at runtime use the Watches tab to see the values of the fields.

If you're in a build, you can add a Lua Console component and use it to print the values, such as:

Code: Select all

return Quest["DOG_HELP_Quest"].target1