Is possible to create a custom node that hide the script logic?

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

When i write a script logic like:

class_name First
extends Node2D

func method_a() -> void:

func method_b() -> void:

First appears as option when adding nodes to the scene but when you do so, the script comes with the node (not like the core nodes that the logic its hidden).

My solution right now is to always warn user that this script is only to be used with extends but i don’t like it because gives to much opportunity for the user use wrongly.

There is a simple way to hide my code from the user?

Real code:

:bust_in_silhouette: Reply From: Adrasteon

You probably need to create a plugin in your project. You can check this page of the godot documentation.

Transforming to a plugin and using add_custom_type didn’t solve.
Using add_custom_type and giving a class_name seems to work like the same thing. They will always create a node with my script attached.

I didn’t want to risk the user writing in the main script logic, that’s why i’m adding warnings that tell the user that it needs to attach another script to the node. But this can get very confuse for the user.

thiagola92 | 2023-04-23 16:04