0 votes

I have a quest log showing active quests and am trying to remove a quest once it has been completed. But the quest log (specifically the itemlist showing the active quests) behaves a bit weird:

The quests are added by calling the add_quest() function, which works fine.

func add_quest():
var activequests = QM.Quests.ActiveQuests
if quest_act < activequests.size():
    $QuestList.add_item(activequests[quest_act])
    quest_act += 1
else:
    return

Without the removal, getting the second quest from the NPC just adds a new item with its proper description when pressed, as intended. However, when I implement the following remove_quest() function, things look strange to me:

func remove_quest(questname, questdesc):
if questname in QM.Quests.ActiveQuests:
    var removed_quest = QM.Quests.ActiveQuests.find(questname)
    QM.Quests.ActiveQuests.erase(questname)
    QM.Quests.QuestDescription.erase(questdesc)
    $QuestList.remove_item(removed_quest)
    $QuestDescription.text = ""
    quest_act -= 1

The item gets deleted properly (as verified with print statements for debugging), but when I open the quest log again after completing the quest, the item is still displayed. Of course when I click it, I get the error "Invalid get index '0' (on base: 'Array')."
Selection function:

func _on_QuestList_item_selected(index):
var quest_description = QM.Quests.QuestDescription[index]
$QuestDescription.text = quest_description

However, if I complete Quest1 and then accept Quest2 (thus removing one and adding a new item), the quest log then still shows the item "Quest1", but when selected displays the correct quest description for Quest2.

Does anyone have an idea what is going on here? The entire GUI is set to Process, so that shouldn't be the issue.

Godot version 3.3 stable
in Engine by (55 points)

One thing you could check: Is the index for the ActiveQuest the same as the QuestItemList in your remove function?

Thanks.
Yes, the QM.Quests.ActiveQuests.find() returns 0 in my tests (as expected for the first quest) and when I use that variable for $QuestList.getitemtext(), I get the correct quest name back.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.