🔢 stewbeet.plugins.auto.scoreboard_constants
📄 Source Code: stewbeet/plugins/auto/scoreboard_constants/__init__.py 🔗
📋 Overview
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:

🎯 Purpose
- 🔢 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
🔗 Dependencies
- ✅ 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
⚙️ 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}.data
📋 Configuration 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