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}.data scoreboard 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

yaml
pipeline:
  - ...
  - stewbeet.plugins.auto.scoreboard_constants
  - ...

# No configuration required - plugin runs automatically
# Scans all functions for the pattern: #{integer} {project_id}.data

Configuration Options

OptionTypeDefaultDescription
Pattern DetectionautomaticEnabledScans all functions for #{integer} {project_id}.data
Initialization TargetautomaticLoad functionWrites set commands to the project's load file
DeduplicationautomaticEnabledDuplicate constant values are collected once via a set
SortingautomaticAscendingConstants 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}.data for 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