Jump to content

AddIngredientValues does not add, but overrides


Serpens
  • Pending

At the moment I'm dealing with the Waiter mod, that adds alot new cooking recipes and therefore also new Ingredient Tags.

http://steamcommunity.com/sharedfiles/filedetails/?id=381565292

I wondered, why the author wrote things like:
AddIngredientValues({"fish", "eel"}, {meat=0.5, fish=1, seafood=1})
Just to add a seafood Tag...since the function is called "ADD..." and not "OverwriteIngredientValues".

But it seems AddIngredientValues really overwrites the tags. It is a mystery to me, why it was called "Add.." if this is not the case?

So to write a proper mod, that does not overwrites everything, one would have to use sth like this:
 

local cooking = require("cooking")
local ing = cooking.ingredients

local function NewTabl(tab,k,v) -- k has to be string
    if type(k)=="string" then
        tab[k] = v -- cause it is not possible to add a new key plus value and return it in one step?
    end
    return(tab)
end

function ingredientpostinit()
    AddIngredientValues({"fish"}, NewTabl(ing["fish"].tags,"seafood",1))
end

I think my code is also not the best... When I deal with "ing" without deepcopying it, I might change the game ingredients directly...
You see, it is unnecessarily complicated...
And I was not able to call the GetIngredientValues() function from the cooking script...

 

Of course most modders does not use such a complicated construct and just overrides...

So I think you as the devs should make a mod function, that allows to really ADD new things. Of course also a Remove function would be good.


Steps to Reproduce
see scripts/cooking.lua for the function, you will see that it just overrides



User Feedback


DarkXero told me a much simpler solution.
But problem still is, that there are modders twho don't know that they have to do it that way, because of the misleading name of the AddIngredientValues function... it should be named like "Set..." ... But of course you can't simply change a functions name.. maybe you find another solution to make it more clear.
http://forums.kleientertainment.com/topic/69732-addingredientvalues-waiter-mod/?do=findComment&comment=806162

Edited by Serpens

Share this comment


Link to comment
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...