Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | denxi |
EDIT: Answered my own question.
Sorry for the poor title, but I’m not exactly sure how to word this. Essentially I’m trying to use variable variables, and I’m not sure what the syntax is in Godot (for reference, in PHP it’s PHP: Variable variables - Manual
func selectLevel(level):
var LevelManager = get_node("/root/LevelManager")
LevelManager.gotoScene(LevelManager.level)
I’m trying to get something to call the function selectLevel with the argument being which ever variable was selected, and have it choose the corresponding variable in LevelManager. So if the player clicks on a button that says “LevelOne”, the button sends a signal to run select_level(“LevelOne”), and then the LevelManager runs gotoScene with the argument being a different variable within LevelManager, named LevelOne.
Currently it just crashes because it’s trying to find LevelManager.level, which doesn’t exist, instead of swapping out the .level with .LevelOne.
If someone can show me what the correct method of using variable variables is in Godot, that’d be appreciated.