Provides pandas-like expressions capabilities to the bolt extension of mecha
Project description
bolt-expressions
a
pandas
-esque API for creating expressions within bolt
Introduction
Bolt is a scripting language which mixes both python and mcfunction. This package amplifies this language by adding an API for creating fluent expressions loosely based off of the pandas
syntax. These expressions are use for simplifying large bits of scoreboard and storage operation allowing you to swiftly create complex operations with the ease of normal programming.
from bolt_expressions import Scoreboard
math = Scoreboard.objective("math")
# or `math = Scoreboard("math")`
math["@s"] = math["@r"] * 10 + math["@r"] + 100
->
scoreboard players operations $i0 bolt.expressions.temp = @r math
scoreboard players operations $i0 bolt.expressions.temp *= #10 bolt.expressions.int
scoreboard players operations $i1 bolt.expressions.temp = @r math
scoreboard players add $i1 bolt.expressions.temp 100
scoreboard players operations $i0 bolt.expressions.temp += $i1 bolt.expressions.temp
scoreboard players operations @s math = $i0 bolt.expressions.temp
Installation
The package can be installed with pip
. Note, you must have both beet
and mecha
installed to use this package.
$ pip install bolt-expressions
Getting started
This package is designed to be used within any bolt
script (either a .mcfunction
or bolt
file) inside a mecha.contrib.bolt
enabled project. Note, bolt-expressions
is not a plugin (yet), so there's no need to require
bolt-expressions
.
require:
- mecha.contrib.bolt
pipeline:
- mecha
Once you've enabled bolt, you are able to import the python package directly inside your bolt script.
from bolt_expressions import Scoreboard, Storage
Any usage of the bolt_expressions
package will require you to inject the current beet context into the API objects. Then, you can create an objective and start creating expressions.
math = Scoreboard.objective("math")
entity_id = Scoreboard.objective("entity_id")
math["@s"] += 10
Features
- Robust API supporting Scoreboards, Storage, Blocks, and Entities
- Provides an interface to manipulate large, complex mathematical expressions simplily
- Allows you to interopt custom variables with normal commands (soon)
Checkout some examples over at our docs!
Contributing
Contributions are welcome. Make sure to first open an issue discussing the problem or the new feature before creating a pull request. The project uses poetry
.
$ poetry install
You can run the tests with poetry run pytest
.
$ poetry run pytest
The project must type-check with pyright
. If you're using VSCode the pylance
extension should report diagnostics automatically. You can also install the type-checker locally with npm install
and run it from the command-line.
$ npm run watch
$ npm run check
The code follows the black
code style. Import statements are sorted with isort
.
$ poetry run isort bolt_expressions examples tests
$ poetry run black bolt_expressions examples tests
$ poetry run black --check bolt_expressions examples tests
License - MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for bolt_expressions-0.4.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35e4d720446b0bf7f258ab5fa8251c1d3addd757f52ce730e1014da9f4070ead |
|
MD5 | 29203c06e5de460068d6cbe42fbab823 |
|
BLAKE2b-256 | 329223b7eaade198ef07de203e7125f8cc93367122265011506f83a1d96799d8 |