Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | trumpetfish1 |
I would like to have the contents of my OptionButton load from different dictionaries depending upon from which scene it is loaded. If loaded from the “Beginner” scene (with both (res://Beginner.tscn) and Node name “Beginner”, it will have beginner items, if from the “Advanced” scene, advanced items. These menus are never loaded at the same time.
extends OptionButton
var context = Node.get_tree().get_root().get_node()
func _ready():
add_items()
pass
func add_items():
if context == "Beginner":
self.add_item("beginner item")
if context == "Advanced":
self.add_item("advanced item")
Currently am getting 'Invalid call. Nonexistant function ‘get_tree’ in base ‘GDScriptNativeClass’, and the list remains unpopulated.
If I take out “Node.”, it cant “get root in bade ‘null instance’”…
Essentially, it’s not even getting the tree… Not sure if the debugger is referring to Native language, or the that some things just cant be done in certain nodes… THX!