defold / defold/defold

Add support for enum script component properties

Open
#10,912 0 comments 11 reactions 0 assignees View on GitHub
bob editor engine feature request go_property
Dominant language
C++
Stars
6.3k
Forks
455
Avg merge
1d 21h
Merged PRs (30d)
127

Description

**Is your feature request related to a problem? Please describe (REQUIRED):**
Inconvenience of usage of script component properties with e.g. hashes, than can have typos.

![Image](https://github.com/user-attachments/assets/070a2dce-feec-4619-be94-d46cff983b03)

**Describe the solution you'd like (REQUIRED):**
Allow to use a table of hashes in go property API to define a "enum" of available values (hashes or integers?) to choose from.

```lua
go.property("card_types", { hash("special_card_1"), hash("special_card_2"), hash("normal_card_1") })
go.property("spawn_amount", { 2, 5, 10 })
```

Then in Properties Pane in Editor - those can be selected from a drop-down menu (similarly like e.g. some GUI properties:)

![Image](https://github.com/user-attachments/assets/cc984a84-6005-4279-9ec1-e53c88a713f9)

**Describe alternatives you've considered (REQUIRED):**
Group several other existing properties into a "group" ?

```lua
go.property("type_1", 1)
go.property("type_2", 2)
...
go.group_properties({"type_1", "type_2", ... })
```

**Additional context (OPTIONAL):**
https://forum.defold.com/t/enum-script-properties/12620

Similar:
https://github.com/defold/defold/issues/10655

Contributor guide

Open the contributing guide

Research direction

Start by tracing the go.property API and the Editor Properties Pane described in the issue. Read related issue #10655 and the linked forum discussion, then clarify the representation of enum hashes or integers and verify that the selected values appear as a dropdown in the editor.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.