bolt-expressions


Namebolt-expressions JSON
Version 0.16.0 PyPI version JSON
download
home_pagehttps://github.com/rx-modules/bolt-expressions
SummaryProvides pandas-like expressions capabilities to the bolt extension of mecha
upload_time2024-02-23 22:16:49
maintainer
docs_urlNone
authorrx97
requires_python>=3.10,<4.0
licenseMIT
keywords beet minecraft bolt mecha expressions
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # bolt-expressions

[![GitHub Actions](https://github.com/rx-modules/bolt-expressions/workflows/CI/badge.svg)](https://github.com/rx-modules/bolt-expressions/actions)
[![PyPI](https://img.shields.io/pypi/v/bolt-expressions.svg)](https://pypi.org/project/bolt-expressions/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/bolt-expressions.svg)](https://pypi.org/project/bolt-expressions/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![Discord](https://img.shields.io/discord/900530660677156924?color=7289DA&label=discord&logo=discord&logoColor=fff)](https://discord.gg/98MdSGMm8j)

> 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.

```py
from bolt_expressions import Scoreboard, Data

math = Scoreboard.objective("math")
storage = Data.storage(example:temp)

stack = storage.hotbar[0]

math["@s"] = stack.Count * math["$cost"] + math["$value"] - stack.tag.discount * 0.75
```
->
```mcfunction
execute store result score @s math run data get storage example:temp hotbar[0].Count 1
scoreboard players operation @s math *= $cost math
scoreboard players operation @s math += $value math
execute store result score $i1 bolt.expr.temp run data get storage example:temp hotbar[0].tag.discount 0.75
scoreboard players operation @s math -= $i1 bolt.expr.temp
```

## Installation

The package can be installed with `pip`. Note, you must have `beet`, `mecha` and `bolt` installed to use this package.

```bash
$ 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 `bolt` enabled project. 

```yaml
require:
    - bolt
    - bolt_expressions

pipeline:
    - mecha
```

Once you've required `bolt` and `bolt_expressions`, you are able to import the python package directly inside your bolt script.

```py
from bolt_expressions import Scoreboard, Data
```
Now you're free to use the API objects. Create objectives, block, storage and entity nbt sources to easily write expressions as simple or complex as you like to make it.

```py
math = Scoreboard.objective("math")
executor = Data.entity("@s")
block = Data.block("~ ~ ~")
storage = Data.storage(example:storage)

math["$value"] = math["$points"] + executor.Health*10 + block.Items[0].Count - storage.discount

storage.values.append(math["$value"])
```
->
```mcfunction
execute store result score $value math run data get entity @s Health 10
scoreboard players operation $value math += $points math
execute store result score $i1 bolt.expr.temp run data get block ~ ~ ~ Items[0].Count 1
scoreboard players operation $value math += $i1 bolt.expr.temp
execute store result score $i2 bolt.expr.temp run data get storage example:storage discount 1
scoreboard players operation $value math -= $i2 bolt.expr.temp
data modify storage example:storage values append value 0
execute store result storage example:storage values[-1] int 1 run scoreboard players get $value math
```

## Features

- Robust API supporting Scoreboards, Storage, Blocks, and Entities
- Provides an interface to manipulate large, complex mathematical expressions simplily
- Automatically initializes objectives and score constants
- Allows you to interopt custom variables with normal commands

Checkout some examples over at our [docs](https://rx-modules.github.io/bolt-expressions/)!

## 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`](https://python-poetry.org).

```bash
$ poetry install
```

You can run the tests with `poetry run pytest`.

```bash
$ poetry run pytest
```

The project must type-check with [`pyright`](https://github.com/microsoft/pyright). If you're using VSCode the [`pylance`](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance) extension should report diagnostics automatically. You can also install the type-checker locally with `npm install` and run it from the command-line.

```bash
$ npm run watch
$ npm run check
```

The code follows the [`black`](https://github.com/psf/black) code style. Import statements are sorted with [`isort`](https://pycqa.github.io/isort/).

```bash
$ poetry run isort bolt_expressions examples tests
$ poetry run black bolt_expressions examples tests
$ poetry run black --check bolt_expressions examples tests
```

---

License - [MIT](https://github.com/rx-modules/bolt-expressions/blob/main/LICENSE)


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rx-modules/bolt-expressions",
    "name": "bolt-expressions",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "beet,minecraft,bolt,mecha,expressions",
    "author": "rx97",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/90/81/35084e3e587cc7d35491fdd567a17063795b41d1e52767a3c36570ae73fc/bolt_expressions-0.16.0.tar.gz",
    "platform": null,
    "description": "# bolt-expressions\n\n[![GitHub Actions](https://github.com/rx-modules/bolt-expressions/workflows/CI/badge.svg)](https://github.com/rx-modules/bolt-expressions/actions)\n[![PyPI](https://img.shields.io/pypi/v/bolt-expressions.svg)](https://pypi.org/project/bolt-expressions/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/bolt-expressions.svg)](https://pypi.org/project/bolt-expressions/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n[![Discord](https://img.shields.io/discord/900530660677156924?color=7289DA&label=discord&logo=discord&logoColor=fff)](https://discord.gg/98MdSGMm8j)\n\n> a `pandas`-esque API for creating expressions within bolt\n\n## Introduction\n\nBolt 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.\n\n```py\nfrom bolt_expressions import Scoreboard, Data\n\nmath = Scoreboard.objective(\"math\")\nstorage = Data.storage(example:temp)\n\nstack = storage.hotbar[0]\n\nmath[\"@s\"] = stack.Count * math[\"$cost\"] + math[\"$value\"] - stack.tag.discount * 0.75\n```\n->\n```mcfunction\nexecute store result score @s math run data get storage example:temp hotbar[0].Count 1\nscoreboard players operation @s math *= $cost math\nscoreboard players operation @s math += $value math\nexecute store result score $i1 bolt.expr.temp run data get storage example:temp hotbar[0].tag.discount 0.75\nscoreboard players operation @s math -= $i1 bolt.expr.temp\n```\n\n## Installation\n\nThe package can be installed with `pip`. Note, you must have `beet`, `mecha` and `bolt` installed to use this package.\n\n```bash\n$ pip install bolt-expressions\n```\n\n## Getting started\n\nThis package is designed to be used within any `bolt` script (either a `.mcfunction` or `bolt` file) inside a `bolt` enabled project. \n\n```yaml\nrequire:\n    - bolt\n    - bolt_expressions\n\npipeline:\n    - mecha\n```\n\nOnce you've required `bolt` and `bolt_expressions`, you are able to import the python package directly inside your bolt script.\n\n```py\nfrom bolt_expressions import Scoreboard, Data\n```\nNow you're free to use the API objects. Create objectives, block, storage and entity nbt sources to easily write expressions as simple or complex as you like to make it.\n\n```py\nmath = Scoreboard.objective(\"math\")\nexecutor = Data.entity(\"@s\")\nblock = Data.block(\"~ ~ ~\")\nstorage = Data.storage(example:storage)\n\nmath[\"$value\"] = math[\"$points\"] + executor.Health*10 + block.Items[0].Count - storage.discount\n\nstorage.values.append(math[\"$value\"])\n```\n->\n```mcfunction\nexecute store result score $value math run data get entity @s Health 10\nscoreboard players operation $value math += $points math\nexecute store result score $i1 bolt.expr.temp run data get block ~ ~ ~ Items[0].Count 1\nscoreboard players operation $value math += $i1 bolt.expr.temp\nexecute store result score $i2 bolt.expr.temp run data get storage example:storage discount 1\nscoreboard players operation $value math -= $i2 bolt.expr.temp\ndata modify storage example:storage values append value 0\nexecute store result storage example:storage values[-1] int 1 run scoreboard players get $value math\n```\n\n## Features\n\n- Robust API supporting Scoreboards, Storage, Blocks, and Entities\n- Provides an interface to manipulate large, complex mathematical expressions simplily\n- Automatically initializes objectives and score constants\n- Allows you to interopt custom variables with normal commands\n\nCheckout some examples over at our [docs](https://rx-modules.github.io/bolt-expressions/)!\n\n## Contributing\n\nContributions 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`](https://python-poetry.org).\n\n```bash\n$ poetry install\n```\n\nYou can run the tests with `poetry run pytest`.\n\n```bash\n$ poetry run pytest\n```\n\nThe project must type-check with [`pyright`](https://github.com/microsoft/pyright). If you're using VSCode the [`pylance`](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance) extension should report diagnostics automatically. You can also install the type-checker locally with `npm install` and run it from the command-line.\n\n```bash\n$ npm run watch\n$ npm run check\n```\n\nThe code follows the [`black`](https://github.com/psf/black) code style. Import statements are sorted with [`isort`](https://pycqa.github.io/isort/).\n\n```bash\n$ poetry run isort bolt_expressions examples tests\n$ poetry run black bolt_expressions examples tests\n$ poetry run black --check bolt_expressions examples tests\n```\n\n---\n\nLicense - [MIT](https://github.com/rx-modules/bolt-expressions/blob/main/LICENSE)\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Provides pandas-like expressions capabilities to the bolt extension of mecha",
    "version": "0.16.0",
    "project_urls": {
        "Documentation": "https://rx-modules.github.io/bolt-expressions/",
        "Homepage": "https://github.com/rx-modules/bolt-expressions",
        "Repository": "https://github.com/rx-modules/bolt-expressions"
    },
    "split_keywords": [
        "beet",
        "minecraft",
        "bolt",
        "mecha",
        "expressions"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0ffa620f1673d374cb85fab0a96b879dfcef23373b118c92a15ed8bdb035b1d3",
                "md5": "6b441299587f49ae7186fb555bf83634",
                "sha256": "805428befeddf1f86c6150ac022643166912d1614c09be1d228c95f9731cc989"
            },
            "downloads": -1,
            "filename": "bolt_expressions-0.16.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6b441299587f49ae7186fb555bf83634",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 43870,
            "upload_time": "2024-02-23T22:16:47",
            "upload_time_iso_8601": "2024-02-23T22:16:47.547072Z",
            "url": "https://files.pythonhosted.org/packages/0f/fa/620f1673d374cb85fab0a96b879dfcef23373b118c92a15ed8bdb035b1d3/bolt_expressions-0.16.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "908135084e3e587cc7d35491fdd567a17063795b41d1e52767a3c36570ae73fc",
                "md5": "b4233ff29bdf34b4d9e4d9aba4da1068",
                "sha256": "9e6faddf713bb9d7670575b6c1d1f6eca9a038e533f31cac23b6e03784db4637"
            },
            "downloads": -1,
            "filename": "bolt_expressions-0.16.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b4233ff29bdf34b4d9e4d9aba4da1068",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 39201,
            "upload_time": "2024-02-23T22:16:49",
            "upload_time_iso_8601": "2024-02-23T22:16:49.706121Z",
            "url": "https://files.pythonhosted.org/packages/90/81/35084e3e587cc7d35491fdd567a17063795b41d1e52767a3c36570ae73fc/bolt_expressions-0.16.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-23 22:16:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rx-modules",
    "github_project": "bolt-expressions",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "bolt-expressions"
}
        
Elapsed time: 0.19374s