Need help adding a variable to an existing entity

Place to get help with not working mods / modding interface.
Post Reply
Bokrug
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue May 03, 2016 2:57 pm
Contact:

Need help adding a variable to an existing entity

Post 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
    }
Attachments
multi-mine_0.1.0.7z
(574 Bytes) Downloaded 70 times

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Need help adding a variable to an existing entity

Post by prg »

Code: Select all

data.raw["resource"]["iron-ore"].minable.count = 2
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Bokrug
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue May 03, 2016 2:57 pm
Contact:

Re: Need help adding a variable to an existing entity

Post by Bokrug »

None of them work I assume because it treats count as an existing expression which it isn't.

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Need help adding a variable to an existing entity

Post by prg »

Pretty sure the code I posted works for me.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Bokrug
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue May 03, 2016 2:57 pm
Contact:

Re: Need help adding a variable to an existing entity

Post 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.

Post Reply

Return to “Modding help”