Candy Logo

Dropdowns
A field has a dropdown when its schema declares a dropdown key for it (see Line Schemas). The list is either written in the schema, or computed by a dropdown script. A dropdown never restricts a field: the user can always type another value. Picking an item writes its value in the field. A Fixed List Write the items in the schema. No code is needed.
"dropdown": { "items": [ { "label": "Once", "value": "1" }, { "label": "Loop forever", "value": "-1" }, { "label": "Don't play", "value": "0" } ] }
An item is:
ItemDescription
{ "label": "Loop forever", "value": "-1" }Writes its value. The menu displays the label, followed by the value in parentheses when the two differ: "Loop forever (-1)". Don't repeat the value in the label.
{ "label": "Colors", "items": [ ... ] }A submenu, opened when hovered.
{ "separator": true }A line between items.
Values are always texts. Built-In Lists A dropdown can use one of the lists Candy Dialogue Creator already computes, by naming it in provider:
DropdownLists
{ "provider": "actors" }The project's Actors, and its Roles in a submenu, written with the Role symbol.
{ "provider": "project_data", "kind": "Flags" }One kind of data from Settings > Project > Data: Actors, Roles, Flags, Dispositions, Effect_Players or CS_Paths.
{ "provider": "conversations" }The Conversations of the Dialogue.
{ "provider": "blocks", "conversation_field": "Conversation" }The Blocks of the Conversation named in the field beside it, or of the Line's own Conversation.
{ "provider": "line_markers", "conversation_field": "Conversation", "block_field": "Block" }The Line Marks of that Block.
{ "provider": "scenes", "folder": "Player_Input_Scenes" }The scenes of one of the folders of Settings > Project > Paths.
{ "provider": "project_scenes" }Every scene of the project, as res:// paths.
{ "provider": "dialogue_modes" }The project's Dialogue Modes.
{ "provider": "languages" }The languages of Settings > Languages & Tags.
{ "provider": "command_types" }Every Command, by category.
Adding Instead of Replacing For a field that accepts several values, add "pick": "append": picking an item appends it to the field's text, after a comma, instead of replacing that text.
"dropdown": { "provider": "project_data", "kind": "Dispositions", "pick": "append" }
A Dropdown Script For a list of your own that must be computed, such as the items of your game read from a file, write a script. Place it in a mod's Dropdowns folder. Its file name is the provider's name. Mods/My_Game/Dropdowns/items.gd:
extends RefCounted func get_items(config: Dictionary, context: Dictionary) -> Array: var items: Array = [] for item_name in ["Potion", "Key", "Map"]: items.append({ "label": item_name, "value": item_name }) return items
In a schema:
"dropdown": { "provider": "items" }
  • config is the field's dropdown dictionary, so a schema can pass the script settings of its own.
  • context describes where the dropdown was opened from: it contains line_path, field_path and line_type.
  • The function returns the items, written as above. An item can contain a submenu.
The list is built each time the dropdown opens, so it's always current. A script with the file name of a built-in one replaces it. Filling the Field Beside An item can also write the sibling fields of the one it's picked from, with siblings:
{ "label": "Potion", "value": "Potion", "siblings": { "Amount": "1" } }
Picking this item writes "Potion" in its field and "1" in the Amount field of the same level, as one undo step. The "No Override" Item A field whose default is "null" always receives a No override (null) item at the top of its dropdown, with or without a list of its own. Don't add one yourself.