Respackopts/docs/old/expand.md

31 lines
1.2 KiB
Markdown
Raw Normal View History

2021-09-15 15:17:32 +02:00
# Resource expansion
2021-09-14 19:46:33 +02:00
You can use the `expansions` block in your .rpo to replace content with a value computed through executing a custom [starscript](https://github.com/MeteorDevelopment/starscript/wiki).
All values are available in starscript like this: `<pack id>.<entry>`
2021-08-30 14:38:03 +02:00
## Example:
en_us.json.rpo:
```
"expansions": {
"lights": "{lumi.subcategoryTest.enableLang}",
"mode": "{lumi.debugMode}",
"normal": "{lumi.numTest * lumi.subcategoryTest.numberInSub}",
"lumi": "model",
"regeneration": "Industrie"
}
```
en_us.json:
```
{
"rpo.lumi": "${lumi} ${lights}",
"rpo.lumi.tonemap": "Tonemap mode",
"rpo.tooltip.lumi.tonemap": "Tooltip test",
"rpo.lumi.pbr": "Enable PBR",
"rpo.lumi.debugMode": "Debug Mode",
"rpo.lumi.debugMode.normal": "${normal} Mode",
"rpo.lumi.waterVertexWavy": "Wavy water model",
"rpo.tooltip.lumi.subcategoryTest.sliderTest": "Yayyy"
}
```
# Explanation
The expansions block contains a key ("lights") and a script, which is executed when the file is loaded. All instances of the key (formatted as ${name} -> ${lights} in this example) will be replaced by the result of the script. Make sure to only use this feature on text files as unexpected results my occur otherwise