This sounds like a dangerous idea (arbitrary code execution by an attacker), what is your use case?
post
replies:
found a few examples of how to do it on a github issue:
var script = GDScript.new()
script.source_code = "func say_hello():\n\tprint(\"Hello!\")"
script.reload()
var script_instance = script.new()
script_instance.call("say_hello")
var MyClass = load("myclass.gd")
var instance = MyClass.new()
assert(instance.get_script() == MyClass)
Are you perhaps looking for an Expression?
I think that is probably as close as you can get to what you want to do.
replies:
permalink
fedilink
source
parent
This seems to be the exact thing I am searching for, thanks! I have run into an interesting hickup tho. One can pass self to the expression so that it uses the node as the base, but the expression doesn't seem to have access to autoloads. The error I'm getting there looks something like this: Invalid named index 'ExampleAutoload' for base type Object EDIT: Turns out I need to pass these individually as arguments essentially.
all 7 comments