Can I add lines to a function from another script and function?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MaaaxiKing

In there should be the do_something() function. I want to write lines in this function from another script.

:bust_in_silhouette: Reply From: blockchan

Yes it’s possible and called “inheritance”

create do do_something in, then at the top of

extends SecondScript

I’d have to to extends “res://Scripts/”, however this isn’t what I wanted to have. I’ll give you an example:





Control (inherited from BaseGame.tscn)

func do_something():

func _ready():
print ($Control.rect_size)


(this is just an example how it could work)
Of course, the added code wouldn’t be seeable for us, it would be there like if you did $Control.add_child(
If extended, $Control wouldn’t be found.

MaaaxiKing | 2020-05-13 15:44