- check_circle Functions
Published Jun 14th, 2021, 6/14/21 11:39 am
- 2,032 views, 4 today
- 0 downloads, 0 today
5
This python program generates a datapack config menu with options for toggles, adjustable values (integers), folding sections and uninstall section. Examples are included in the download.
Version 1.1: Added config pages, as displayed at the bottom of this document. v1.2: Added selectors
Options can be changed in the file config.py, in which you specify the options available and formatting of them.
If the program is run with the -c option, it will generate a blank template datapack (without any config settings), e.g.
If you run the generator from inside the datapacks, as given in the examples, they are run with path `..`, and if you have the generator directory outside the datapack, it needs the path `<datapack>`.
3 examples are included:
- **Blank:** this is the base generator, with no datapack generated
- **Template:** this is the result after `python generator.py -c ..` is run from the blank example.
- **Full:** this is the result after `python generator.py ..` is run on the template example. This includes the full settings menu, including a `init_config` function to initialize the config's values.
In this example, settings `config.py` to:
Generates
All scoreboard values are given in the `SB` class, which pairs the values together, and registers the value for initialisation (if a default value is given) and deletion (on uninstallation).
Because I am hilarious, the `Book` class is used as the outer class for a set of `Page`s. A menu page is also generated along with the listed ones, which will list all available pages. Books can be nested in theory, however this has not been properly tested, and will give you two layers of navigation bars.
`xxx_commands` are extra commands to run on enable, disable, increase or decrease as required. My ETL Utils Datapack shows this all in use.
*For more information on settings available, read the Blank example readme; for more on the template read the Template example; and for more on files generated read the Full example.
Also added option to generate basic blank datapack with required advancements and uninstall function based of initial settings in `config.py`.
Version 1.1: Added config pages, as displayed at the bottom of this document. v1.2: Added selectors
Example
Usage
The generator is run withpython generator.py
pointed to the root directory of your datapack (where pack.mcmeta is). The path can be passed in as the only argument to the program, e.g. python generator.py "../datapack". Options can be changed in the file config.py, in which you specify the options available and formatting of them.
If the program is run with the -c option, it will generate a blank template datapack (without any config settings), e.g.
python generator.py -c "../datapack"
Can be optionally given with the path as well. This includes the necessary advancements to display the pack's installation, and a `load` and `uninstall` function ready for the configs. No existing files will be deleted in this process. If you run the generator from inside the datapacks, as given in the examples, they are run with path `..`, and if you have the generator directory outside the datapack, it needs the path `<datapack>`.
3 examples are included:
- **Blank:** this is the base generator, with no datapack generated
- **Template:** this is the result after `python generator.py -c ..` is run from the blank example.
- **Full:** this is the result after `python generator.py ..` is run on the template example. This includes the full settings menu, including a `init_config` function to initialize the config's values.
In this example, settings `config.py` to:
config = Config(
Title("ETL Pages Example", "v0.0", "#BBBBBB"),
Book([
Page("First page", "1", [
Foldable("Fold", SB("fold", "enabled", 1), "fold", "fold_config",
Toggle("Toggle", SB("toggle", "enabled", 1), "toggle",
enable_commands="tellraw @s \"toggle enabled\"",
disable_commands="tellraw @s \"toggle disabled\""),
Adjustable("Adjust", SB("val1", "values", 5), "adjust", SB("one", "constants", 1),
min_sb=SB("zero", "constants", 0), max_sb=SB("five", "constants", 5)),
AdjustToggle("Adjust Toggle", SB("ad_tog", "enabled", 1), "ad_toggle", SB("val2", "values", 5), SB("five", "constants"),
min_sb=SB("zero", "constants", 0),
enable_commands="tellraw @s \"adj toggle enabled\"",
inc_commands="tellraw @s \"adj toggle increased\""),
)
]),
Page("Second page", "2", [
Text("{\"text\":\"More Text\", \"color\":\"#FF0000\"}"),
Toggle("Toggle 2", SB("toggle2", "enabled", 1), "toggle2"),
Select("Selector", SB("select", "enabled", 1), [
Choice("One", "one", 1),
Choice("Two", "two", 2),
Choice("Three", "three", 3),
Choice("Four", "four", 4),
])
]),
Page("Third page", "3", [
Text("{\"text\":\"Yet More Text\", \"color\":\"#FF0000\"}"),
Adjustable("Adjust", SB("val3", "values", 5), "adjust2", SB("one", "constants", 1),
min_sb=SB("zero", "constants", 0), max_sb=SB("five", "constants", 5)),
])
], SB("menu", "pages", 0)),
Uninstall("ETL Config Example")
)
Generates
All scoreboard values are given in the `SB` class, which pairs the values together, and registers the value for initialisation (if a default value is given) and deletion (on uninstallation).
Because I am hilarious, the `Book` class is used as the outer class for a set of `Page`s. A menu page is also generated along with the listed ones, which will list all available pages. Books can be nested in theory, however this has not been properly tested, and will give you two layers of navigation bars.
`xxx_commands` are extra commands to run on enable, disable, increase or decrease as required. My ETL Utils Datapack shows this all in use.
*For more information on settings available, read the Blank example readme; for more on the template read the Template example; and for more on files generated read the Full example.
Version History
v1
Initial version, basic support and examplesv1.1
Added pages, along with refactoring into multiple folders and adding the `SB` class to represent scoreboards for consistent representation. Settings now changed in `config.py` and still ran with `generator.py`.Also added option to generate basic blank datapack with required advancements and uninstall function based of initial settings in `config.py`.
v1.2
Added support for a multiple-choice selector. Cannot overlap values.Compatibility | Minecraft 1.13 |
to | Minecraft 1.18 |
Tags |
tools/tracking
5167616
119
datapack-settings-generator
Create an account or sign in to comment.