-
Notifications
You must be signed in to change notification settings - Fork 3
05. Skills & Traits tool: Talents
The Talents tool is the central metadata catalog for all Stats, Skills and Traits defined in your project.
-
Role: In the external GDScript files (
stat_block.gd,skill_set.gdandtrait_block.gd) stats, skills and traits are defined as simple variables. The Talents tool bridges the gap by providing the human-readable data and Custom Data associated with those variables.- Access: The system is managed by three separate singletons and resource classes:
-
Stats:
NexusForge.Stats(Class:NFStatManager) -
Skills:
NexusForge.Skills(Class:NFSkillManager) -
Traits:
NexusForge.Traits(Class:NFTraitManager)
-
Storage:
- All metadata for stats is stored in a separate
StatCatalogresource file. - All metadata for skills is stored in a single
SkillCatalogresource file. - All metadata for traits is stored in a separate
TraitCatalogresource file.
- All metadata for stats is stored in a separate
Warning
The resource files that these tools use gets cleaned on project export to remove old and redundant information. It is not recommended to manually edit the storage of any of the files as the data could be removed from the exported copy.
The catalogues manage two distinct types of entries.
- Exported attributes: These are attributes defined statically in the GDScript files. (Exported variables)
-
Custom Talents: These are talents created dynamically at runtime via the API (
create_*).
Important
-
Creating a custom stat/skill/talent during runtime will make all current and future instances of
SkillSetandTraitBlockalso register it with an initial value of0. -
Erasing a custom stat/skill/talent WON'T remove it from existing instances of
StatBlock,SkillSetandTraitBlockbut will prevent new instances of them from having it.
Note
- Only the valid variables declared on each script will appear on the drop-down.
- The items in the drop-downs are always sorted alphabetically.
- These drop-downs automatically update when the external GDScript files[1] are saved.
The Talents editor features a simple, three-column layout for focused data entry, managing the catalogue resources from one window.
- Layout: The window is divided into an identical Stat Column (Left), Skills Column (Center) and Traits Column (Right).
- Drop-downs: A drop-down at the top of each column lists all available stats/skills/traits.
-
Metadata Fields: Selecting an ID from the drop-down loads the fields for that attribute:
- Name: The human-readable display name.
- Description: The text description.
- Custom Data: A tree view for storing custom data.
For more information and examples on defining attributes see Defining Character Attributes.
The catalogues (accessed via NexusForge.Stats, NexusForge.Skills, NexusForge.Traits) manages all metadata for skills.
Tip
All attributes (exported & custom) can be accessed and updated directly with their ID. e.g. NexusForge.Stats.health, NexusForge.Skills.shield & NexusForge.Traits.cold_resist
Caution
Unlike other modules, accessing a non-existing attribute directly WILL return an object. To verify if the attribute is valid call is_valid(). e.g. NexusForge.Stats.invalid_stat.is_valid(): Will return false.
| Signal | Arguments | Emitted |
|---|---|---|
[stat/skill/trait]_created |
id: StringName
|
Emitted when a new custom attribute is created. |
[stat/skill/trait]_erased |
id: StringName
|
Emitted when a custom attribute is erased. |
stat_clamping_toggled |
stat_id: StringName
|
Emmited when the clamping of a stat was enabled or disabled. |
stat_clamping_changed |
stat_id: StringName
|
Emitted when a value of a clamped stat changed. |
| Function Signature | Purpose | Return Type |
|---|---|---|
stats()/skills()/traits() |
Returns a list containing all registered attributes. | Array[StringName] |
get_*_name(id) |
Returns the display name for the attribute. | String |
get_*_description(id) |
Returns the description for the attribute. | String |
get_*_data(id, data_id) |
Returns the value of a specific custom data key. |
Variant or null if key doesn't exist. |
| Function Signature | Purpose | Return Type |
|---|---|---|
allows_greater(id) |
Returns true if the stat allows for greater values. | Bool |
allows_lesser(id) |
Returns true if the stat allows for lesser values. | Bool |
get_range_max(id) |
Returns the maximum allowed value for the stat. | Float |
get_range_min(id) |
Returns the minimum allowed value for the stat. | Float |
| Function Signature | Purpose | Notes |
|---|---|---|
set_*_name(id, new_name) |
Sets the display name for the attribute. | |
set_*_description(id, new_description) |
Sets the description for the attribute. | |
set_*_data(id, data_key, data) |
Sets a custom data key-value pair. | If data is null, the key is erased. |
| Function Signature | Purpose | Return Type |
|---|---|---|
has_*(id) |
Checks if the attribute is registered | Bool |
has_*_data(id, data_id) |
Checks if the skill/trait has the specified custom data key. | Bool |
| Function Signature | Purpose | Notes |
|---|---|---|
| erase_*(id) | Removes an entry. | Entries for exported attributes can't be removed. |
clear_*_data(id) |
Clears the entire custom data dictionary for the attribute. |
Tip
All attributes (exported & custom) can be accessed and updated directly with their ID. e.g. character.stats.health, character.skills.shield & character.traits.cold_resist
The StatBlock, SkillSet and TraitBlock class are the data objects used on the CharacterSheet. It holds the actual numerical values for a specific attribute.
| Function Signature | Purpose | Return Type | Notes |
|---|---|---|---|
stats(), skills()/traits() |
Returns a list with all Exported attributes. | Array[StringName] |
Static methods. |
custom_*() |
Returns a list with the custom attributes registered in this specific instance. | Array[StringName] |
|
custom_[skill/trait]_value(id) |
Gets the value of an instance-specific custom skill/trait. | Integer |
Returns -1 if the skill/trait doesn't exist. |
| Function Signature | Purpose | Return Type |
|---|---|---|
has_custom(id: StringName) |
Checks if the instance has a custom attribute. | Bool |
| Function Signature | Purpose | Notes |
|---|---|---|
create_custom(id, value/type) |
Creates a custom trait for this instance only. | The second argument is for value on skills and traits. For stats it takes either enum TYPE_INT or TYPE_FLOAT
|
To update a custom attribute access it directly after creation. e.g. NexusForge.Stats.my_custom_stat = 6
Caution
When updating a custom attribute always ensure the stat exists by using has_custom. If the attribute doesn't exist it'll trigger a null-access error.
- Default paths:
-
StatBlock:
res://addons/nexus_forge/resources/stat_block.gd. -
SkillSet:
res://addons/nexus_forge/resources/skill_set.gd. -
TraitBlock:
res://addons/nexus_forge/resources/trait_block.gd.