store() on nested dictionaries

Is there a way to update a nested dictionary variable in touchdesigner? ie in my case i have a dictionary called filters, nested inside a dictionary called master. things like n.store(‘master.filters.somevariable’, ‘test’) or n.store([‘master’][‘filters’][‘somevariable’], ‘test’) etc do not pass as it appears the class cannot seem to handle array or dictionary traversal. My only way around it is to n.fetch() the entire dictionary, perform an update in the variable and then n.store() that allover again. Doesn’t seem very efficient.

this seems to be my closest shot so far, its interesting as I would ordinarily expect this command to completely erase any other variables stored in master. But it seems to retain any others that I haven’t build into my build which is handy.
data = op(“/data”)
master = { “master” : { “filters” : { “test”: “test2” } } }
data.store(“”, master)

ie so if I had master/filters/test3 stored in there, the above command would not remove test3.

Once you get a storage item you can change it without re-storing and the storage will be updated. Although unless you use dependencies any nodes pointing to those storage items may not update and will need to be force cooked to update.

ie. A = me.fetch('MyData') A['someKey']['anotherKey'] = 5

now A[‘someKey’][‘anotherKey’] is updated in storage. in order to avoid the cooking issue:

parent().store('MyData', tdu.Dependency(myData))

now to assign to MyData:

A = me.fetch('MyData')
A.val['someKey']['anotherKey'] = 5

cheers
Keith

1 Like