Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Luka38 | |
Old Version | Published before Godot 3 was released. |
Is there a way to get an object from another node’s dictionary by using a string?
For example, I have a dictionary named levelList with a bunch of objects all named level_000, level_001, level_002…
Now I want to access, let’s say, levelList.level_000 in another node.
var levelSpace
var levelList
var level
export var levelName = "" # where I give the name (like "level_000")
func _ready():
levelSpace = get_parent().get_parent().get_parent().get_parent()
levelList = levelSpace.levelList
print(levelList.level_000) # this works
level = levelList.level_000
print(level) # this doesn't work
And levelList.get(level_000) also doesn’t work.
Thanks for the help in advance