
Publisher
jospete
Cables
A set of scripts to bridge the "signal gap" between scenes. Signals carry values, Cables carry Signals.
This plugin has been mirrored from the Godot Asset Library.
The plugin author is in no way affiliated with Gadget.
If you are the author of this plugin and would like this mirror removed, please contact support@gadgetgodot.com.
godot-addon-cables
A Godot plugin to serve as an alternative to Autoload Event Buses for a more visual / editor gameplay design approach.
The implementation of this addon is very much inspired by Ryan Hipple's 2017 Talk
on using Unity ScriptableObjects as an alternative to singletons.
Usage
The general flow for usage is:
- Right-click on any folder in the
FileSystemtab >Create New>Resource... - Search for
Cable> clickCreate - Name your Cable something useful like
player_death_event.tresorplayer_health_value.tres - Produce values on the cable - this can be done by either producing a value on a
Cabledirectly vianotify()(e.g. for primitive values likefloat,string,int,booletc), or using aCableValueProducernode to emit events / data on the cable. (NOTE: the producer should generally be a child of the node that is producing the value) - Consume values from the cable - this can be done by adding the
CableValueConsumernode as a child of the node that wishes to consume value updates
Available Producer Types:
CableNodeValueProducer- sendsNodereferences across theCable, and automatically clears the reference when the producer gets destroyedCableButtonEventProduer- translates a button click into aCableevent; useful for quickly wiring up UI across scenesCableInputEventProducer- translates input actions intoCableevents; this is more niche, but can help cover some edge cases for prototyping
See the examples folder for more granular implementation details
Best Practices
It is best to use Cable resources for global state, such has passing data to UI components (e.g. player health ratio to a healthbar widget) or sharing atomic data like enemy count, number of coins, or even a shared node reference to a manager script that holds these.
You should not use Cable resources when transferring local state, such as watching a single monster's CollisionShape2D.area_entered event to apply damage to the monster (e.g., multiple instances of the monster scene will all broadcast on the same assigned Cable resource).