I’ve gotten some help here to make a tree with a range. With a tree node and the code:
func _ready():
var root = quest_tree.create_item()
root.set_text(0, "Settings")
var section1 = quest_tree.create_item(root)
section1.set_range(0, 2)
section1.set_cell_mode(0, TreeItem.CELL_MODE_RANGE)
section1.set_editable(0, true)
section1.set_range_config(0, 0, 10, 1)
var section2 = quest_tree.create_item(root)
section2.set_range(0, 2)
section2.set_cell_mode(0, TreeItem.CELL_MODE_RANGE)
section2.set_editable(0, true)
section2.set_range_config(0, 0, 10, 1)
I get:
Now I need to grab all the values from this list, i.e. 5 and 2.
I see that I need to use get_range()
this should grab the value.
However I don’t understand the syntax. What I’ve tried is:
var children = quest_tree.get_root().get_children()
This returns an array with all treelist items in it, and it seems like get_range does not work on that?
With this code:
var children = quest_tree.get_root().get_children()
# try to get value of first child (value is 5)
print(children.get_range(0))]
I get the error:
Invalid call. Nonexistent function ‘get_range’ in base ‘Array[TreeItem]’.