Change a recipe on event
Posted: Fri Jun 07, 2019 8:42 am
Hi everyone, I'm attempting to write a mod that will reduce the crafting time of items the more you make them. I'm trying to edit the recipe energy_required everytime the item is finished being crafted, but this doesn't seem to work. If you could point me in the right direction it would be greatly appreciated!
Code: Select all
local function reduce_energy_required(recipe)
data.raw["recipe"][recipe.name].energy = data.raw["recipe"][recipe.name].energy_requrired * 0.999
end
script.on_event({defines.events.on_player_crafted_item},
function (e)
reduce_energy_required(e.recipe)
end
)