CrowdControl
The CrowdControl singleton is available in every script. All signals are emitted on the main thread.
Properties
| Property | Type | Use |
|---|---|---|
paused | bool | While true, no effects start and the timers of timed effects stop. |
auto_starting_session | bool | Start a session as soon as the login is done. Set it before connecting. |
Connection and Login
| Method | Use |
|---|---|
connect_to_crowd_control() -> Error | Loads the effects and opens the connection. |
close() | Stops the session and closes the connection. disconnected is emitted when done. |
is_connected_to_crowd_control() -> bool | Whether the connection is open. |
login() | Starts the login. Emits auth_code_received, then logged_in or login_failed. |
logout() | Stops the session, logs out, and forgets the stored login. |
is_logged_in() -> bool | Whether a valid login is available. |
extend_token() -> bool | Asks for a later expiry of the login. The plugin does this on its own before the login runs out. |
ping() | Sends a ping, pong_received is emitted on the reply. The plugin keeps the connection alive on its own. |
| Signal | When |
|---|---|
connecting | A connection attempt started. |
connected | The connection is open. |
disconnected | The connection closed. |
connection_errored(err: Error) | The connection failed or dropped. The plugin reconnects on its own. |
logged_in | A login is available. Also emitted after every reconnect. |
logged_out | No usable login: none stored, expired, revoked, or logout() was called. |
auth_code_received(code: String, url: String) | The streamer has to sign in at url. |
login_failed(message: String) | The login attempt failed. |
token_refreshed | The login was extended. |
pong_received | Crowd Control answered a ping. |
Sessions
| Method | Use |
|---|---|
start_session() | Starts a game session for the configured Game Pack. |
stop_session() | Stops the running session. |
is_session_active() -> bool | Whether a session is running. |
get_streamer_user() -> StreamUser | The logged in streamer, once their profile has loaded. |
get_interact_link() -> String | The link viewers use to buy effects, empty if not logged in. |
launch_interact_link() | Opens that link in the browser. |
| Signal | When |
|---|---|
session_started | A session is running. |
session_stopped | The session ended. |
session_start_failed(message: String) | The session could not be started. |
session_paused(paused: bool) | The streamer paused or resumed ordering. |
Effects
| Method | Use |
|---|---|
get_effect(id: StringName) -> CCEffect | The effect with that ID, null if there is none. |
test_effect(effect: CCEffect) | Runs an effect locally, without contacting Crowd Control. |
stop_all_effects() | Ends every running timed effect and refunds every waiting request. |
stop_effect(instance: CCEffectInstanceTimed) | Ends a running timed effect early. |
pause_effect(effect: CCEffectTimed) | Pauses a running timed effect. |
resume_effect(effect: CCEffectTimed) | Resumes it. |
reset_effect(effect: CCEffectTimed) | Restarts its timer. |
| Signal | When |
|---|---|
effect_requested(effect: CCEffect) | A request arrived. |
effect_queued(instance: CCEffectInstance) | The request is waiting to start. |
effect_dequeued(id: String, result: int) | The request left the queue, with its EffectResult. |
effect_triggered(instance: CCEffectInstance) | An effect ran successfully. |
effect_started(instance: CCEffectInstanceTimed) | A timed effect started. |
effect_stopped(instance: CCEffectInstanceTimed) | A timed effect ended. |
effect_paused(instance: CCEffectInstanceTimed) | A timed effect was paused through pause_effect(). |
effect_resumed(instance: CCEffectInstanceTimed) | A timed effect was resumed through resume_effect(). |
effect_reset(instance: CCEffectInstanceTimed) | The timer of a timed effect was reset. |
Effect Menu
Each function returns false if nothing could be reported. The message argument is optional.
| Method | Use |
|---|---|
show_effects(effect_ids: PackedStringArray, message := "") -> bool | List the effects in the menu. |
hide_effects(effect_ids: PackedStringArray, message := "") -> bool | Remove the effects from the menu. |
enable_effects(effect_ids: PackedStringArray, message := "") -> bool | Allow the effects to be bought. |
disable_effects(effect_ids: PackedStringArray, message := "") -> bool | Keep the effects listed but not buyable. |
show_all_effects(message := "") -> bool | As above, for every effect. |
hide_all_effects(message := "") -> bool | |
enable_all_effects(message := "") -> bool | |
disable_all_effects(message := "") -> bool |
Events, Metadata, and Coins
| Method | Use |
|---|---|
trigger_event(event_id: String, args := {}) -> bool | Reports a game event defined in the Game Pack. |
update_metadata(key: String, value: Variant) -> bool | Updates one metadata value of the Game Pack. |
update_metadata_values(values: Dictionary) -> bool | Updates several at once. |
| Signal | When |
|---|---|
coins_exchanged(amount: int, exchanger: StreamUser) | A viewer exchanged coins. The amount is 0 without the pubsub.private:read scope. |
message_display_requested(message: String, duration: float, icon: Texture2D) | The plugin has a status message for the player, such as "Started the Crowd Control session!". |
Custom Effects
| Method | Use |
|---|---|
can_upload_custom_effects() -> bool | Whether the login has the custom-effects:write scope. |
upload_custom_effects(mode := CUSTOM_EFFECTS_MERGE) -> bool | Uploads every effect marked as custom. |
delete_custom_effects(effect_ids: PackedStringArray) -> bool | Deletes custom effects by ID. |
delete_all_custom_effects() -> bool | Deletes every custom effect of the Game Pack. |
| Signal | When |
|---|---|
custom_effects_updated(success: bool, message: String) | An upload or delete finished. |
Modes: CUSTOM_EFFECTS_MERGE, CUSTOM_EFFECTS_REPLACE_ALL, CUSTOM_EFFECTS_REPLACE_PARTIAL.
