Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Adham | |
Old Version | Published before Godot 3 was released. |
I have a script’s source that I will need to extract variables from. I have to do it in this way due to an implementation detail. Here’s what I did:
var script = GDScript.new()
script.set_source_code('var test_var = "hi this is working"')
var my_object = Node.new()
var my_object.set_script(script)
Then I do:
print(my_object.test_var) #I get an error! Doesn't work :(
Why doesn’t it work? What am I missing here? I tried using Reference.new() but still doesn’t work!
I can propose an alternative.
Load script like node.
Rihard | 2016-07-19 11:57