Skip to content

Commit

Permalink
Improved the getting-started tutorial and some pages linked from it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nusiq committed Dec 14, 2024
1 parent a8e231b commit 4d25b60
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 56 deletions.
10 changes: 9 additions & 1 deletion docs/filter-types/node-filters.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
(node-filters)=
# NodeJS Filters

As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications.
NodeJS is a JavaScript runtime. It is also the most popular option for writing Regolith filters. If you're making Minecraft packs, there's a good chance you're already familiar with JavaScript, and have NodeJS installed.

You can download NodeJS here: [https://nodejs.org/en/download/package-manager](https://nodejs.org/en/download/package-manager)

```{note}
The [Gametests](https://github.com/Bedrock-OSS/regolith-filters/tree/master/gametests) filter is a very notable filter that for many users could be the main selling point of Regolith. Gametests is a filter that lets you use TypeScript. It compiles the script in the pack using ESBuild.
The unusual name of the filter is a relic of its time of creation. The filter was created before current Scripting API was released. At that time, Minecraft only had the "gametest" API designed for writing tests of the packs. The filter was named after this API.
```

## Installing NodeJS

Expand Down
10 changes: 5 additions & 5 deletions docs/filter-types/python-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ Python is an interpreted high-level general-purpose programming language.
(installing-python)=
## Installing Python

Before you can run Python filters, you will need to [install python](https://www.python.org/downloads/).
Before you can run Python filters, you will need to [install Python](https://www.python.org/downloads/).

Please ensure that you add python to your path:
Please ensure that you add Python to your path:

![](./python-filters/python-path.png)

We recommend that you download more or less recent versions of Python.

```{warning}
It's generally not acceptable to install python via the Microsoft Store. Python installed from here is not available on the path. If you have trouble running Python filters with Regolith, please reinstall using the link above.
It's generally not acceptable to install Python via the Microsoft Store. Python installed from here is not available on the path. If you have trouble running Python filters with Regolith, please reinstall using the link above.
```

## Running Python code as Filter

The syntax for running a python script is this:
The syntax for running a Python script is this:

```json
{
Expand All @@ -45,7 +45,7 @@ When developing a Python filter with dependencies, you must create this file. Yo

[Python Venvs](https://docs.python.org/3/library/venv.html) are flexible, lightweight "virtual environments".

Regolith uses venvs to install dependencies, since it will prevent your global installation space from becoming polluted. When you install a python filter with dependencies, they will be installed into a venv, stored in `.regolith/cache/venvs/`.
Regolith uses venvs to install dependencies, since it will prevent your global installation space from becoming polluted. When you install a Python filter with dependencies, they will be installed into a venv, stored in `.regolith/cache/venvs/`.

By default, all filters will share a single venv.

Expand Down
27 changes: 9 additions & 18 deletions docs/introduction/additional-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,14 @@ Git is the most popular version control system in the world. It is also the most

You can download Git from its website: [https://git-scm.com/download/](https://git-scm.com/download/)

(nodejs-dependency)=
## NodeJS
NodeJS is a JavaScript runtime. It is also the most popular option for writing Regolith filters. If you're making Minecraft packs, there's a good chance you're already familiar with JavaScript, and have NodeJS installed.
## Filter Runners

You can download NodeJS here: [https://nodejs.org/en/download/package-manager](https://nodejs.org/en/download/package-manager)
Regolith supports filters written in various programming languages. To run these filters, you will need to install the appropriate runtime. You can find the installation instruction for each runtime in pages dedicated to different filter types:
- {ref}`Python<python-filters>`
- {ref}`NodeJS<node-filters>`
- {ref}`Deno<deno-filters>`
- {ref}`Java<java-filters>`
- {ref}`Nim<nim-filters>`
- {ref}`.NET<dotnet-filters>`

```{note}
The [Gametests](https://github.com/Bedrock-OSS/regolith-filters/tree/master/gametests) filter is a very notable filter that for many users could be the main selling point of Regolith. Gametests is a filter that lets you use TypeScript. It compiles the script in the pack using ESBuild.
The unusual name of the filter is a relic of its time of creation. The filter was created before current Scripting API was released. At that time, Minecraft only had the "gametest" API designed for writing tests of the packs. The filter was named after this API.
```

(python-dependency)=
## Python
Python is the second most popular language for writing Regolith filters.

We provide detailed instructions on how to install Python in the {ref}`Python Filters<installing-python>` section.

## Other languages
Regolith supports many other languages, including writing shell scripts (which basically unlocks the ability to use any language). You can find instructions for installing these languages in the documentation for each filter type.
The runtimes are optional, unless you want to use filters written in the corresponding language.
45 changes: 13 additions & 32 deletions docs/introduction/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ Regolith is a command line application. It assumes some familiarity with how to

This tutorial will guide you through basic usage of Regolith. It assumes that you've already installed Regolith. If you haven't, please refer to the {ref}`installation<installation>` page.

At the end of the tutorial, it is shown how to add filter from the internet into your project and run it. Installing filters requires Git, and the filter used as an example runs in Python. If you want to follow allong, you will need get these dependencies. To learn more about getting Git and Python please refer to the {ref}`Additional Dependencies<additional-dependencies>` section.
At the end of the tutorial, it is shown how to add filter from the internet into your project and run it. Installing filters requires Git, and the filter used as an example runs in Python. If you want to follow allong, you will need get these dependencies. To learn more about getting Git please refer to the {ref}`Additional Dependencies<additional-dependencies>` section. To get the instructions for installing Python, please refer to the {ref}`Python Filters<python-filters>` section.

## Creating a new Project

To create a new project, navigate to a blank folder, and run `regolith init`. This will create a few files:
To create a new project, navigate to a blank folder, and run the following command:
```
regolith init
```

This will create a few files:

```text
πŸ“‚ example-project
Expand All @@ -24,12 +29,12 @@ To create a new project, navigate to a blank folder, and run `regolith init`. Th
```

In short:
- `.regolith` is a special folder that regolith uses to store data. You don't need to look here.
- `.regolith` is a special folder that Regolith uses to store data. You don't need to look here.
- `packs/BP` stores your behavior pack.
- `packs/RP` stores your resource pack.
- `packs/data` is a special folder that filters can use to store data.
- `config.json` is the configuration file for Regolith.
- `.gitignore` is a file which tells {ref}`Git source control<git-dependency>` to ignore certain files. It's not a partof of Regolith but we highly recommend using Git to manage your projects.
- `.gitignore` is a file which tells {ref}`Git source control<git-dependency>` to ignore certain files. It's not a part of of Regolith but we highly recommend using Git to manage your projects.

## Basic Project Configuration

Expand Down Expand Up @@ -71,23 +76,9 @@ You can read more about the `config.json` file in the {ref}`Configuration File<c

## Adding Pack Files

At this point, you will want to add some files into your regolith project. If you have an existing project, you can copy/paste the files into the `RP` (resource pack) and `BP` (behavior pack) folders.
At this point, you will want to add some files into your Regolith project. If you have an existing project, you can copy/paste the files into the `RP` (resource pack) and `BP` (behavior pack) folders.

If you don't have an addon prepared, you may also create a fresh one directly in your project folder, following the normal rules. Add a `manifest.json`, a `pack_icon.png`, and any other files you want. The files should go directly into the `RP` and `BP` folders, like this:

```text
πŸ“‚ example-project
πŸ“‚ packs
πŸ“‚ BP
πŸ“‚ entities
πŸ“„ frog.behavior.json
πŸ“„ manifest.json
πŸ–ΌοΈ pack_icon.png
πŸ“‚ data
πŸ“‚ RP/...
πŸ“„ .gitignore
πŸ“„ config.json
```
If you don't have an addon prepared, you may use files from the [example project prepared for this tutorial](https://github.com/Bedrock-OSS/regolith-docs-tutorial-resources/releases/tag/1.4.1-getting-started). You can copy the into the content of `RP.zip` and `BP.zip` into the `RP` and `BP` folders respectively or you can get the full (final) version of the project from the `getting-started-full-project.zip` file.

```{note}
Regolith supports creating purely resource-pack- or behavior-pack-oriented projects. If your project doesn't have a resource pack or behavior pack, you can simply remove the appropriate field from the `config.json` file, and remove the `RP` or `BP` folder.
Expand All @@ -103,11 +94,7 @@ It runs the default {ref}`profile<profiles>`. If unmodified, the `default` profi

## Adding your first Filter

```{warning}
Installing filters from the internet requires Git. Additionally, the filter used as an example in this section requires Python to run. You can read more about these dependencies in the {ref}`Additional Dependencies<additional-dependencies>` section.
```

Regolith contains a very powerful filter system, that allows you to write filters in many languages, as well as running existing filters from the internet. For now, we will simply use the {ref}`standard library<standard-library>`, which is a set of filters maintained by Bedrock-OSS.
Regolith contains a very powerful filter system, that allows you to write filters in many languages, as well as running existing filters from the internet. For now, we will simply use the {ref}`standard library<standard-library>`, which is a set of filters maintained by creators of Regolith - Bedrock-OSS.

As an example, we will use the `texture_list` filter, which automatically creates the `textures_list.json` file for you. To learn more about this file, and why automating it is helpful, read [here](https://wiki.bedrock.dev/concepts/textures-list.html).

Expand All @@ -132,14 +119,8 @@ Alternatively, you can just run `regolith install texture_list`, and manually ad
]
}
```
Now, you can re-run `regolith run`. This time, Regolith will not only copy your packs into the `com.mojang` folder, but also create the `textures_list.json` file for you in your resource pack. Every time you run regolith, this file will be re-created, based on your current textures. No need to manually edit it ever again!
Now, you can re-run `regolith run`. This time, Regolith will not only copy your packs into the development folders in `com.mojang` folder, but also create the `textures_list.json` file for you in your resource pack. Every time you run Regolith, this file will be re-created, based on your current textures. No need to manually edit it ever again!

```{warning}
If your project doesn't have any textures, than `texture_list.json` will simply create a blank file `[]`. Consider adding some textures to see the filter at work!
```

## What's Next?

Now that you've created your first Regolith project, and installed your first filters, you are well on your way to being a Regolith expert! You should check out the {ref}`standard library<standard-library>`, to see if additional filters might be useful for you.

Otherwise, you can learn about writing {ref}`custom filters<custom-filters>` or dive deeper into Regolith commands by reading about {ref}`Filter Run Modes<filter-run-modes>` and {ref}`Installing and Updating Filters<filter-installation>`.

0 comments on commit 4d25b60

Please sign in to comment.