-
Notifications
You must be signed in to change notification settings - Fork 3
03. Characters tool: Persona
The Characters tool is designed for the creation and management of individual entity data using the custom CharacterSheet resource class. This tool allows developers to centralize and configure all static data specific to a single character.
- Access: Characters are loaded directly as resources (no singleton required).
-
Storage: Every character is saved as a separate
.tresfile, featuring a custom icon. Double-clicking the file opens it directly in the editor. -
Creation Methods:
- Using Godot's built-in Resource Creator and then double-clicking the resulting file.
- Going to the Nexus Forge editor, selecting the Characters tab, clicking the "three dots" menu, and choosing "Create character".
| Field | Type | Notes |
|---|---|---|
| Character ID | StringName |
Unique identifier. |
| Name | String |
Display name. |
| Gender | enum |
Defined by members of the Gender enum[1]. |
| Species | StringName |
ID of the species defined on the Species tool. |
| Custom Data | Dictionary |
Contains data unique to that character |
| Stats | StatBlock |
Defines the character stat values |
| Skills | SkillSet |
Defines the character skills values |
| Traits | TraitBlock |
Defines the character trait values |
Tip
You can set up so that all new characters created have default custom data entries by modifying the constant DEFAULT_DATA on the CharacterSheet[1] resource.
Important
This tool doesn't enforce an unique ID system. It's up to the developer that each character's ID is unique.
The structure of the stat, skill and trait block is dictated by external GDScript files. The editor updates automatically upon script save.
| Block | Script File | Type Requirement |
|---|---|---|
| Stats | stat_block.gd |
Must be an @export[2] variable of class RangeInt or RangeFloat. |
| Skills | skill_set.gd |
Must be an @export[2] variable of type int. |
| Traits | trait_block.gd |
Must be an @export[2] variable of type int. |
For more information and examples on defining attributes see Defining Character Attributes.
Note
Linking a character to a Species ID is not mandatory for runtime functionality but is vital for editor convenience and data enrichment.
- Defining a species allows easy access to shared custom data (e.g., species-wide resistances) and enables the import function.
- Subspecies are visually indicated in the dropdown by parentheses (e.g.,
Blue Slime (Slime)). - A button next to the species dropdown allows the user to import the Stats, Skills, and Traits from the selected Species/Subspecies. If a Subspecies is selected, the tool resolves values via recursive inheritance[3].
This feature is available only for Stats.
- A button located to the left of the stat's name expands Min/Max limit controls.
- Expanding the section reveals two Spinboxes ("Min" and "Max") and their corresponding Checkboxes.
- Enabling a checkbox enforces the boundary.
-
Visual Cue: The icon on the button changes to show which limits are active:
- Min Enabled: The left part of the icon turns green.
- Max Enabled: The right part of the icon turns green.
Important
Enabling limits automatically enforces it on the stat value. If it falls outside the enabled limit, it is automatically clamped to the limit.
The CharacterSheet functions as a data container. Runtime interaction involves accessing the nested attribute objects.
Important
This class has a custom constructor CharacterSheet.new_character(). This method ensures all objects are initialized correctly and initial custom data is properly assigned.
These objects manage the value and constraints of a Stat.
| Variable | Type | Purpose | Notes |
|---|---|---|---|
value |
int / float
|
The current active value of the stat. | |
min_value / max_value |
int / float
|
The defined boundary limits. | |
allow_lesser |
bool |
If true, the value is allowed to fall below min_value. |
When set to true, it immeditaly clamps value to enforce the limit. |
allow_greater |
bool |
If true, the value is allowed to exceed max_value. |
When set to true, it immeditaly clamps value to enforce the limit. |
Runtime Access Example:
# Load the character sheet resource
var my_character_sheet: CharacterSheet = load("res://path/to/my_character.tres")
# Accessing a value
var current_health: float = my_character_sheet.stats.health.value
# Setting a new min value
my_character_sheet.stats.health.min_value = 10.0Caution
RangeInt and RangeFloat are distinct classes, changing the type of an existing stat variable (@export var health: RangeInt to RangeFloat) will result in the loss of all saved values for that stat in the resource file upon loading it.
To prevent data loss do the following:
- Load ALL your characters
- Change the variable type
- Save the script (
Ctrl + S). - Save all the characters (
Ctrl + Sagain).
- The default path for the CharacterSheet script is
res://addons/nexus_forge/resources/character_sheet.gd - The variable must have the export flag. For example
@exportor@export_storage. - Species stat/skill/trait inheritance means that the subspecies will have the parent's value unless the subspecies has it enabled itself. This goes from the subspecies all the way to the top species.