Respackopts/docs/old/conditional.md
2021-08-30 15:03:33 +02:00

1.5 KiB

Conditional Resources

Conditional resources are the simplest use case of respackopts. 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:

{
    "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:

"conditions": [
    "example:option1",
    {
        "or": [
            "example:option2",
            "example:option3",
            {
                "and": [
                    "example:option4",
                    "example:option5"
                ]
            }
        ]
    }
]

The following conditions are supported:

Name Function
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