Respackopts/docs/old/conditional.md

45 lines
1.5 KiB
Markdown
Raw Normal View History

2021-08-30 14:38:03 +02:00
# Conditional Resources
2021-08-30 15:03:33 +02:00
Conditional resources are the simplest use case of respackopts.
2021-08-30 14:38:03 +02:00
To add one, you will need to create an rpo file for your resource.
It needs to be titled by appending `.rpo` to the files name.
For example: If you want `/assets/minecraft/lang/en_us.json` to be configurable, you will need to create `/assets/minecraft/lang/en_us.json.rpo`
If you only want a simple condition, you can use the following template:
```json
{
"conditions": [
"<your pack id>:<your entry>"
]
}
```
You can simply copy the id from your conf.json. The entry will be the name of the entry for things directly under `conf`,
otherwise it will be `category.entry`. For nested categories, names will follow the same schema.
If you have an enum entry ("Select from list"), it will be `category.entry.option`
## Logic
You may also use logic to determine whether conditions are met.
This might look like the following example:
```json
"conditions": [
"example:option1",
{
"or": [
"example:option2",
"example:option3",
{
"and": [
"example:option4",
"example:option5"
]
}
]
}
]
```
2021-08-30 15:03:33 +02:00
The following conditions are supported:
2021-08-30 14:38:03 +02:00
| Name | Function |
--|--
2021-08-30 15:03:33 +02:00
| and | True if all sub-conditions are met |
| or | True if at least one sub-condition is met |
| xor | True if an uneven number of sub-conditions is met |
| nor | True if none od the sub-conditions are met |
| eq | True if all the sub-conditions have the same result |