This script is designed to add the functionality to implement make-shift interfaces to your GDScript Godot project until an official solution is made available.
An explanation of why to use interfaces, and how this script was generally created, Tutemic livestreamed it on YouTube here: Tutemic YouTube tutorial .
If you found this useful, feel free to support Tutemic on YouTube: Tutemic on YouTube by subscribing!
Copy this interface.gd script somewhere in your Godot project folder. Within your Godot project within the Godot editor, make this script an autoload script, with the recommended node name Interface.
To define a custom interface, create a sub-class, as shown in the example below:
class ExampleInterface:
var example_property
signal example_signal
func example_method():
pass
To implement a custom interface you defined above, type the following near the top of any class script (using the example name above):
var implements = Interface.ExampleInterface
To check if a node implements a custom interface you defined above, you may type something like the following anywhere in your codebase:
if Interface.node_implements_interface(myNode, Interface.ExampleInterface):
...