A standard library that adds variables, arithmetic, and relational operators to mcfunction
- mcfunction 100%
This PR adds the `_std_` prefix to some of the remaining internal score-holders in the `_reg` objective. All internal score-holders now follow this convention. Reviewed-on: #14 |
||
|---|---|---|
| data | ||
| .gitignore | ||
| LICENSE | ||
| pack.mcmeta | ||
| README.md | ||
Standard library for mcfunction
mcfstd is a library datapack for Minecraft Java Edition. It adds named integer variables, arithmetic, comparisons, callback helpers, and more on top of vanilla mcfunction commands.
The full documentation lives in the mcfstd wiki
# Set variable 'score' to 10
function var:set { k: "score", v: 10 }
# Add five
function var:math/add { k: "score", v: 5 }
# Check the result
function var:comp/eq { k: "score", v: 15 }
execute if function stdout:true run say score is 15
execute if function stdout:false run say score is not 15
Installation
Download the datapack zip from the releases page and place it directly inside your world's datapacks/ directory.
Reload the world:
reload
Enable the datapack if needed:
datapack enable "file/mcfstd-X-X-X.zip"
Replace X-X-X with the release version you installed.
Features
| Feature | Summary | Documentation |
|---|---|---|
| Variables | Set, unset, copy, move, increment, decrement, and test integer variables | Variables |
| Arithmetic | Add, subtract, multiply, divide, and modulo variables | Arithmetic |
| Comparisons | Compare variables against integers or other variables | Comparisons |
| Function calls | Pass variable values into Minecraft macro functions | Function Calls |
| Standard output | Branch on the result of the previous boolean operation | Standard Output |
| Triggers | Register area enter/leave callbacks and block placement callbacks | Triggers |
| Debugging | Show scoreboards and receive trace output | Debugging |
For a compact list of every public function, see the Function Reference.
Public Namespaces
| Namespace | Purpose |
|---|---|
var: |
Integer variables and operators |
call: |
Call macro functions with variable values as arguments |
trigger: |
Area and block callbacks |
stdout: |
Read the boolean result of the previous comparison |
debug: |
Debug output and scoreboard display helpers |
Functions under z_std: are internal implementation details. See Internal Model for how the datapack stores variables, tracks triggers, and manages macro call storage.