Trying to edit game recipes, what am i doing wrong


Ivysaur

Recommended Posts

Hello,

I've been trying to modify the games recipes through the GetAllRecipes function. The code currently looks like this:

function ChangeRecipes()
    Rec = require "recipe"
    Recipes = Rec.GetAllRecipes()
    
    for i,recipe in ipairs(Recipes) do
        for k,ingredient in ipairs(recipe.ingredients) do
            ingredient.amount = ingredient.amount * 0.5
        end
        recipe.level = TECH.NONE
    end
end

I've had experience with c# and c++ before, but not so much with lua. This code when executed, only makes the game crash without any errors. I've tried Recipes = GLOBAL.GetAllRecipes() and also Recipes = GetAllRecipes(), but it creates the same result.

Link to comment
Share on other sites

The crash may be because some of your recipe amounts end up being half a unit.
That is just speculation through.

you might want to try making it equal the ingredient amount *0.5, rounded up to the nearest whole.

I have no idea how that would be done, or even if it would work.
Just making some guesses

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.