Change a variable in a dictionary

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By liti

Heey Guys and Gilrs

First sorry English is not my first language.
No my problem I have written a Quest dictionary.



Now I want the variable is_Quest_active set to ture with the funtion:

func _activate_Quest(Quest_ID):
QuestDictionary[Quest_ID][“is_Quest_active?”] = true

What happens now is that the variable is_Quest_active remains false and a new entry is added to the dictionary with variable is_Quest_active: true

How can i set is_Quest_active to true?

can someone help me with this problem? thanks in advance :slight_smile:

:bust_in_silhouette: Reply From: njamster

You named the key is_Quest_active but are setting the key is_Quest_active? (with a question mark in the end). Here’s a working example:

var QuestDictionary = {
	"QUEST0": {
		"Quest_Name": "Farming",
		"is_Quest_active": false
	"QUEST1": {
		"Quest_Name": "Mining",
		"is_Quest_active": false

func _ready():
	print("Quests before: ", QuestDictionary)
	print("Quests after: ", QuestDictionary)

func activate_Quest(QuestID):
	QuestDictionary[QuestID]["is_Quest_active"] = true