extends PanelContainer @onready var run_script: Button = %RunScript @onready var code_editor: TextEdit = %CodeEditor # Called when the node enters the scene tree for the first time. func _ready() -> void: %CodeEditor.text = "extends OverlayPlugin\n\nfunc run() -> void:\n\tpass" run_script.pressed.connect(_handle_run_script) func _handle_run_script() -> void: var script = GDScript.new() script.source_code = %CodeEditor.text var error := script.reload() if error != OK: print("Failed to parse script!") return var context: Object = script.new() if not context is OverlayPlugin: print("Script doesn't inherit from OverlayPlugin!") if context.has_method(&"queue_free"): context.queue_free() elif context is RefCounted: context = null else: context.free() return context.ready.connect(func() -> void: context.run(); context.queue_free()) add_child(context)