[Request] ignore bracket errors inside "if" functions if condition fails
Lorelando opened this issue · 5 comments
Adding a recipe inside an "if" function that only runs if a specified mod is present will still prevent the whole script file from running.
It would be quite helpful and allow for more flexible scripts if you could modify a recipe (or something else) differently, if a mod or an item can't be found.
recipes.remove(<minecraft:carpet>);
if(loadedMods in "mymod") {
recipes.addShapeless("carpedfrommod", <minecraft:carpet>, [<mymod:cloth> * 3]);
} else {
recipes.addShapeless("carpedfrommc", <minecraft:carpet>, [<minecraft:wool> * 3]);
}
would make a carped craftable from three cloth from a mod if that mod is present, if that mod is not present it will add a recipe to craft it from three wool.
As of now the script errors (ERROR: misc.zs:18: Could not resolve mymod:cloth) and everything stays the vanilla way.
Any other function that can put part of a script into "quarantine" (maybe a "try"-"catch", that only uses catch if there is a bracket error in try, or an "iferror" like in Excel) would also server the purpose.
If seems like using a combination of #modloaded
and #priority
preprocessors could do the same thing, but in a pretty complicated way, especially if working with multiple possible mods.
If there already if a way to do this in an elegant way, I would be grateful if you let me know and sorry for not having found it :)
- Minecraft: 1.12.2
- Forge: 14.23.2.2611
- Crafttweaker: 1.12-4.1.5
@kindlich I did mention the #modloaded
preprocessor in combination with a #priority
preprocessor, the scripts would be tidier if a bracket error could be contained to a part of a script.
@BloodWorkXGaming #ignoreBracketErrors
only suppresses the error message, not the error itself. At least to my experience and from what the documentation says.
Thanks for your thoughts though.
@BloodWorkXGaming Many thanks for your reply. It made test everything again and it seems recipes.remove(<potionfingers:ring:1>.withTag({}));
is causing an error when Potion Fingers isn't installed. When I remove it, everything works fine. That pretty much solves my issue.
As an afterthought, I guess I should just have uploaded my whole script instead of distilling what I believed caused the error.