Signal Plus for Godot
This is a plugin for the Godot Engine that enhances the scripting workflow by providing intelligent code completion for connecting signals in GDScript.
Features
- Smart Signal Connection Completion: When you are writing code to connect a signal (likely using the
connect
method), pressingCtrl
+Alt
+Space
will trigger intelligent code completion. - Method and Lambda Suggestions: The plugin suggests both regular methods and lambda functions as potential handlers for the signal.
- Visual Differentiation: Suggestions for regular methods and lambda functions are displayed with distinct icons.
- Automatic Code Generation: Upon selecting a suggestion, the plugin automatically generates the basic structure of the method or lambda function, including the necessary arguments based on the signal's parameters.
How to Use
- Install the plugin through the Godot Asset Library or by manually adding the
addons/signal_plus
folder to your project. - Enable the plugin in your Project Settings under the "Plugins" tab.
- When you are in a GDScript and writing code involving the
connect
method:- Ensure your cursor is in a position where you would typically define the method to connect to the signal.
- Press
Ctrl
+Alt
+Space
. - A list of suggested method names (or a lambda structure) will appear.
- Select the desired option. The plugin will then insert the basic function structure into your script.
Installation
Through Godot Asset Library
- Open your Godot project.
- Go to the "AssetLib" tab.
- Search for "Signal Plus".
- Install the plugin.
- Enable the plugin in Project Settings -> Plugins.
Manual Installation
- Download or clone this repository.
- Create an
addons
folder in the root of your Godot project (if it doesn't exist). - Copy the
signal_plus
folder into theaddons
folder. - Enable the plugin in Project Settings -> Plugins.
Limitations
- Might not work well with very complex or non-standard code for accessing objects and signals.
- Relies on simple ways to identify the object emitting the signal (like
self
or basic node paths). - Needs Godot's internal information to know the arguments of a signal.
- Generates basic names for connected methods.
- Assumes consistent code indentation.
Potential New Features
- Suggestion of Existing Functions: When connecting a signal, suggest existing functions in the script that have a compatible signature.
- User Settings for Method Prefix: Allow users to customize the prefix used for generated connection method names (e.g., change
_on_
). - Support Connecting to Internal Node Functions: When connecting a signal from a node, suggest its built-in methods as connection targets (if the signature matches).
- Improved Object Type Detection: Enhance the plugin's ability to identify the type of the signal-emitting object in more complex code scenarios.
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.
License
MIT License