How to define _process function for node created in code? Godot 4

Is there any way to define nodes _process function from code? Without using external script file?

Now my code is like this:
var process_script = load(“res://src/scripts/”)

var mp = = MUSIC_PLAYER;

This works, but it would be great to get rid of that externally loaded script file. Process function just tracks music play position. This could be done also with timer, but I think I might need this anyway approach in the some other case too.

No, it’s not possible.

EDIT: Nevermind, it kinda works:

extends Node

var src = """
extends Node

func _process(delta):
	print('it works')

func _ready() -> void:
	var node =
	var script =
	script.source_code = src
1 Like

Thanks! One external script file less!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.