stewbeet.plugins.auto.scoreboard_constants
The auto.scoreboard_constants plugin automatically detects scoreboard constant usages across all datapack functions
and generates their initialization commands in the load file.
It scans every function for the pattern #{integer} {project_id}.data and produces a sorted list of
scoreboard players set commands, ensuring every constant is properly initialized on load without any manual tracking.
Feature Showcase
Generated scoreboard constants initialization in the load file:
Required: Beet context with functions
Required: Project ID for scoreboard objective namespacing
Position: Should run after all function content is generated but before finalization
Related: Works with any plugin that uses scoreboard constants in mcfunction files
Source Code: stewbeet/plugins/auto/scoreboard_constants/__init__.py
What it does
- Automatically detects all scoreboard constant usages across datapack functions
- Generates
scoreboard players set #{n} {project_id}.data {n}initialization commands - Targets the
{project_id}.datascoreboard objective - Writes constants to the project's load file in sorted numerical order
- Eliminates manual tracking and declaration of scoreboard constants
Configuration
Basic Example Configuration
pipeline:
- ...
- stewbeet.plugins.auto.scoreboard_constants
- ...
# No configuration required - plugin runs automatically
# Scans all functions for the pattern: #{integer} {project_id}.dataConfiguration Options
| Option | Type | Default | Description |
|---|---|---|---|
| Pattern Detection | automatic | Enabled | Scans all functions for #{integer} {project_id}.data |
| Initialization Target | automatic | Load function | Writes set commands to the project's load file |
| Deduplication | automatic | Enabled | Duplicate constant values are collected once via a set |
| Sorting | automatic | Ascending | Constants are sorted numerically before output |
Features
Constant Discovery
Scans every datapack function line by line for scoreboard constant references:
- ๐ฏ Uses compiled regex
#(\d+) {project_id}.datafor efficient detection - ๐ Collects all unique integer constant values into a set for automatic deduplication
- ๐ Processes every function present in the beet pipeline
Load File Generation
Writes sorted initialization commands to the project's load function:
- ๐ Produces
scoreboard players set #{n} {project_id}.data {n}for each discovered constant - ๐ข Sorts constants numerically for deterministic and readable output
- ๐พ Appends the constants block to the existing load file content
- โ Skips output entirely if no constants are found
Next steps
- Writing functions and files: the functions this plugin post-processes.
- All plugins: the rest of the pipeline, in the order it runs.
- Configuring the build: enabling, ordering and configuring plugins.