Inherited scenes and scripts

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

I want to inherit a scene but not the script, to try some polymorphic functions in a inherited script.
Godot doesn’t want to load an inherited script in the inherited scene.
A completely new script works, but it need to maintain the two scripts. The two scenes shares lot of stuffs.
If is it possible how to do this please ?

:bust_in_silhouette: Reply From: brunosxs

You could see what is the script loaded with get_script and then, use set_script at ready(or at process) of the parent node to load another one at runtime…

On the parent node, call the set_script on the child scene with any kind of method you want:

if Input.is_action_pressed("ui_down"):
    get_node("my_awesome_scene").set_script("res://my_other_awesome_script")

Shouldn’t you use set_script(preload("..."))?

Bojidar Marinov | 2016-04-14 08:49

Yup, missed that one, thanks.

brunosxs | 2016-04-14 11:04

:bust_in_silhouette: Reply From: DriNeo

Now it works. Don’t know what I did to make it work. Sorry

But now I’ll try to find how to extends the functions too …

Thanks for the help brunosxs.