I'm trying to make an extension system for my game so that lightweight custom scripts can be loaded at runtime, passed as strings, using GDScript.setsourcecode. This is an simple example of how I use it
var runner = null
runner = Reference.new()
var script = GDScript.new()
var label = null
label.text = "Hello world"
runner.label = get_node("../Label")
When calling dostuff() on the Node that has this script, the runner reference will get a script attached given by the text. This text can define custom behaviour that can be called from the outside (runner.changetext()). It actually works really well for what I want, so that's great.
My only concern is that there seems to be no error control at all in Godot, and I would like to deal with the case that the extension contains invalid code. When running during the tests, it gives an error, of course. I do not want fancy exception handling, just - is there any way to at least ignore the contents of the script gracefully?
Thanks in advance!