I would recommend reconsidering how to organize this data. This problem is likely a nudge to change the design.
But if you really must get at it, packed scenes have a
_bundled dictionary to them, which does contain those values, but it isn't clear exactly the pattern to the alignment of the "names" and "variants" arrays inside it.
Another approach, a bit hacky, but again if you really need to salvage something... TSCN files have those saved export values in plain text, it can be loaded and parsed out.
For a scene of my that has the following:
[node name="Node2D" type="Node2D"]
script = ExtResource( 1 )
_sections_unfolded = [ "Script" ]
number = 12
I have some code roughly like:
var tscn = preload("res://Node2D.tscn")
for item in tscn._bundled:
# Not sure about the alignments.
print(item, " ", tscn._bundled[item])
# Needs casting.
var value = int(get_tscn_value("res://Node2D.tscn", "number"))
func get_tscn_value(path : String, var_name : String) -> String:
var f = File.new()
if(f.open(path, File.READ) == OK):
var line = f.get_line()
if(line.find(var_name + " = ") > -1):
return line.split("= ")