
Example of using RecipeModifierBuilder
iLamirry opened this issue ยท 3 comments
Hi, can you please write an example script using RecipeModifierBuilder.
I am trying to multiply an entire recipe by a number from Smart Interface. I was able to get the interface value, but how to use RecipeModifierBuilder I can't figure out for a few days now.
Somehow I came up with this code, but I don't know what the "key" in addModifier(key, RecipeModifier)
means
MMEvents.onSmartInterfaceUpdate("water_pump", function(event as SmartInterfaceUpdateEvent) {
val ctrl = event.controller;
val data = ctrl.customData;
val map = data.asMap();
map["FluidMultiply"] = event.newData.value; //receive value in event
val FluidMultiply = map["FluidMultiply"];
ctrl.addModifier("key", RecipeModifierBuilder.create("modularmachinery:energy", "input", 10, 1, false).build()));
ctrl.customData = data;
});
Now this script doesn't give errors, but it doesn't change the amount of energy either.
Ok, I realized what the problem was and moved the RecipeModifierBuilder to onMachinePreTick event.
But I encountered a new problem: the inability to change item input.
ctrl.addModifier("ItemInputModifier", RecipeModifierBuilder.create("modularmachinery:item", "input", 2, 1, false).build());
ctrl.addModifier("ItemOutputModifier", RecipeModifierBuilder.create("modularmachinery:item", "output", 2, 1, false).build());
ctrl.addModifier("EnergyInputModifier", RecipeModifierBuilder.create("modularmachinery:energy", "input", 2, 1, false).build());
Output resources are multiplied, input energy is also multiplied, but input resources persistently ignore RecipeModifierBuilder, and there are no errors in the log.