Page 1 of 1

Need help adding a variable to an existing entity

Posted: Tue May 03, 2016 3:21 pm
by Bokrug
A redditor requested a mod to make mining give additional resources and I decided to try it and found that just adding the variable count worked.

Code: Select all

type = "resource",
    name = "iron-ore",
    icon = "__base__/graphics/icons/iron-ore.png",
    flags = {"placeable-neutral"},
    order="a-b-a",
    minable =
    {
      hardness = 0.9,
      mining_particle = "iron-ore-particle",
      mining_time = 2,
      result = "iron-ore",
      count = 2
    }
I've been trying to figure out how to put this in a mod file instead of having to alter the base file but I can't figure out how to add a variable to an existing entity. I've looked at other posts and tried a few variations but none seem to work.

Code: Select all

data:extend
data.raw.resource["iron-ore"].mineable = {count = 2}
data.raw.["resource"]["iron-ore"].mineable = {count = 2}
data.raw.["resource"]["iron-ore"].mineable.count = 2}
data.raw.["resource"]["iron-ore"].mineable.insert(count = 2)
data.raw.resource["iron-ore"].mineable = {
      hardness = 0.9,
      mining_particle = "iron-ore-particle",
      mining_time = 2,
      result = "iron-ore",
      count = 2
    }

Re: Need help adding a variable to an existing entity

Posted: Tue May 03, 2016 3:26 pm
by prg

Code: Select all

data.raw["resource"]["iron-ore"].minable.count = 2

Re: Need help adding a variable to an existing entity

Posted: Tue May 03, 2016 6:17 pm
by Bokrug
None of them work I assume because it treats count as an existing expression which it isn't.

Re: Need help adding a variable to an existing entity

Posted: Tue May 03, 2016 6:34 pm
by prg
Pretty sure the code I posted works for me.

Re: Need help adding a variable to an existing entity

Posted: Tue May 03, 2016 7:20 pm
by Bokrug
After some more looking I realized you were correct. I didn't notice that I had an extra 'e' in minable which you corrected. Thank you.