Effects & Requests
Effects are resources stored in a CCEffectEntries resource. Each request for an effect reaches the script as an instance object.
| Effect class | Instance class | Use |
|---|---|---|
CCEffect | CCEffectInstance | An effect that happens once. |
CCEffectParameters | CCEffectInstanceParameters | An effect with options or a quantity. |
CCEffectTimed | CCEffectInstanceTimed | An effect that lasts for a duration. |
CCEffectEntries
| Member | Use |
|---|---|
effects: Array[CCEffect] | The effects of the game. |
save_pack_zip(path: String) -> Error | Writes the effect pack to upload in the developer portal: menu.json and the effect icons. |
get_manifest() -> String | The menu.json for these effects. |
get_manifest_data() -> Dictionary | The same as a dictionary. |
CCEffect
Properties
| Property | Type | Default | Use |
|---|---|---|---|
id | StringName | Unique ID of the effect: letters, numbers, and underscores. | |
display_name | String | Name shown to viewers. | |
description | String | Description shown to viewers. | |
note | String | Short note shown next to the name. | |
price | int | 10 | Default price in coins, at least 1. |
categories | PackedStringArray | Menu categories. | |
groups | PackedStringArray | Groups the effect belongs to. | |
morality | NEUTRAL, GOOD, EVIL | NEUTRAL | |
orderliness | ORDER_NEUTRAL, ORDERLY, CHAOTIC | ORDER_NEUTRAL | |
visible | bool | true | Whether the effect is listed in the menu. Reported when a session starts and whenever it changes. |
sellable | bool | true | Whether the effect can be bought. Reported the same way. |
session_max | int | 0 | Purchases allowed per session, 0 for no limit. |
pooling_disabled | bool | false | Viewers may not pool coins for the effect. |
conflicts | PackedStringArray | IDs of effects it cannot run alongside. | |
custom | bool | false | Uploaded by the game instead of being part of the effect pack. |
max_retries | int | 3 | How often a request is retried before it is refunded. |
retry_delay | float | 5.0 | Seconds between retries. |
icon | Texture2D | Icon shown in the effect menu, exported with the effect pack. | |
icon_color | Color | For your own UI. |
Methods to Implement
| Method | Use |
|---|---|
_trigger(instance: CCEffectInstance) -> EffectResult | Required. Apply the effect. |
_can_run() -> bool | Optional. Whether the effect can run right now. |
EffectResult
| Value | Meaning |
|---|---|
SUCCESS | The effect happened. |
FAILURE | It could not happen right now; the viewer is refunded. |
UNAVAILABLE | It cannot happen at all; the viewer is refunded. |
RETRY | Try again after retry_delay. |
RUNNING | A timed effect is now active. |
Other Methods
| Method | Use |
|---|---|
get_definition() -> Dictionary | The effect as it appears in menu.json. |
CCEffectInstance
| Method | Use |
|---|---|
get_id() -> String | ID of the request. |
get_effect() -> CCEffect | The effect resource. |
get_effect_id() -> StringName | Its ID. |
get_user() -> StreamUser | The viewer. |
is_test() -> bool | Whether the request is a test. |
is_local() -> bool | Whether it came from CrowdControl.test_effect(). |
get_retry_count() -> int | How often the request has been retried. |
CCEffectParameters
Parameters are edited in the Inspector through parameter_count and parameter_N/name, id, kind, options, min, and max. They can also be built from code:
| Method | Use |
|---|---|
add_item_parameter(name: String, options: PackedStringArray) | Adds a list of options. Its ID is <effect id>_<name in lowercase>. |
add_range_parameter(name: String, min: int, max: int) | Adds a quantity. Name it Quantity to get the ID quantity. |
remove_parameter(idx: int), clear() | Removes one or all parameters. |
get_parameter_count() -> int | Number of parameters. |
get_parameter_id(idx: int) -> String | ID of a parameter. |
CCEffectInstanceParameters
| Method | Use |
|---|---|
get_option_name(id: String) -> String | Name of the option the viewer picked for a parameter. |
get_parameter(id: String) -> Variant | Value of a parameter: an int for quantity. |
get_parameter_names() -> PackedStringArray | IDs of the parameters of the request. |
CCEffectTimed
| Property | Type | Default | Use |
|---|---|---|---|
duration | float | 60.0 | Default duration in seconds, 1 to 600. |
Methods to Implement
| Method | Use |
|---|---|
_start(instance: CCEffectInstanceTimed) -> EffectResult | Required. Apply the change and return RUNNING. |
_stop(instance: CCEffectInstanceTimed, force: bool) -> bool | Required. Undo the change. |
_pause(), _resume(), _reset() | Optional. |
_should_be_running() -> bool | Optional. Whether the effect should currently be active. |
CCEffectInstanceTimed
| Method | Use |
|---|---|
get_duration() -> float | Duration of this request in seconds. |
get_time_left() -> float | Seconds remaining. |
is_paused() -> bool | Whether the effect is paused. |
get_effect_timed() -> CCEffectTimed | The effect resource. |
StreamUser
| Property | Type | Use |
|---|---|---|
name | String | Name of the user. |
display_name | String | Display name of the user. |
profile_icon | Texture2D | Their avatar, once downloaded. |
profile_icon_url | String | Where the avatar comes from. |
roles | PackedStringArray | Roles of the user on the channel. |
origin_site | String | Platform of the streamer, for example twitch. Only set for the streamer. |
| Signal | When |
|---|---|
icon_downloaded | profile_icon is available. |
