Shared systems: how they are built ​
The shared systems are the tools many editors use. In code they have one thing in common: each is a small family of Resource classes that live inside other resources, not in the Database. A requirement is a field of an ability, a reward a field of a quest. They have no id and no file of their own, and they are saved with their owner.
| System | Base class | A type implements | Stored as |
|---|---|---|---|
| Requirements | Requirement | check(entity) | Array[Requirement] |
| Conditions | Condition (EntityCondition, EncounterCondition) | evaluate(argument) (evaluate_entity, evaluate_encounter) | Array[Condition] |
| Rewards | Reward | apply_to_player(player) | Array[Reward] |
| Groups | GroupDefinition | (a database resource; the others store its id) | Array[int] of group ids |
| Text tokens | TextTokens (static) | a resolver callable, to add a token | Plain text with <tokens> |
| Formulas | CalculationFormula, DiminishingReturns | evaluate(points), apply(points) | One resource in a slot |
Groups are the exception that proves the rule: a group has an id and a file because many things point at the same one.
How a type gets into an editor ​
Each family is found by scanning a folder, so a new type is a new script with no registration:
| System | Folder that is scanned | Who scans it |
|---|---|---|
| Requirements | res://addons/chroniclenode/data_classes/requirements/types/ and your own res://src/requirements/ | The add dialog (UnifiedResourceDialog) |
| Rewards | res://addons/chroniclenode/data_classes/rewards/types/ and your own res://src/rewards/ | The same dialog |
| Conditions | .../data_classes/conditions/general/, entity/, encounter/ and your own res://src/conditions/ (the Project category) | The add-condition dialog (ConditionalEditDialog) |
| Conditions on stat effects | the entity conditions folder, res://src/conditions/ and res://src/stat_conditions/ | StatClassScanner |
| Formulas | the formulas folder and res://src/stat_formulas/ | StatClassScanner |
| Diminishing returns | the folder and res://src/stat_diminishing_returns/ | StatClassScanner |
The name in a list is made from the file name. Every family has an addon folder (the types ChronicleNode ships) and a project folder (yours). Put your own types in the project folder: an update of the addon replaces its folders but never res://src/. A script placed in the addon folder is found too, but it is lost when the addon is updated. A project folder that does not exist yet is simply skipped.
The classes ​
Every class has a page, written from the comments in its script. The page of each system lists its classes in a table. The menu on the left groups them the same way.