Is there a way to have a script execute a function on load from within itself?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By leod
:warning: Old Version Published before Godot 3 was released.

I’m looking for a way to have a script that is never added to the scene_tree itself (and as such never has ._ready() called) call some kind of initialization function whenever it’s instanced.

This is just to save me some/a lot of typing if I instance it often, I know I could just run something like an Instance.start() on it every time after instancing it from the other script.
Especially since this makes it so I can’t just onready the instance this way.

:bust_in_silhouette: Reply From: Hooni

I just woke but still I’m pretty sure all classes get called _init() when created an instance with my_class.new(). Can even have arguments added.

Thanks, works just as expected!
Nice to know passing arguments works too, that’s a neat added bonus there.

leod | 2016-09-17 17:58