Updating graphics of installed mods

Place to get help with not working mods / modding interface.
Metalface7
Inserter
Inserter
Posts: 28
Joined: Sat Jun 11, 2016 1:49 pm
Contact:

Updating graphics of installed mods

Post by Metalface7 »

Hello, I'm currently working on a personal project to replace icon graphics for parts of bob's and angels mods, and the process for changing the graphics for an item or recipe is not clear to me. Could someone offer help or maybe an example of a line that could accomplish this task?

Additionally, how can I make sure that it is not overridden by any other mod? It will be hard to tell if my code works if the graphics are being overridden by another mod.

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

Re: Updating graphics of installed mods

Post by prg »

It's generally something like

Code: Select all

data.raw["type"]["name"].the_thing_you_want_to_change = new_value
so in your case maybe

Code: Select all

data.raw["item"]["iron-chest"].icon = "__newicons__/graphics/icons/iron-chest.png"
to do it one by one, or if you have replacement graphics for everything,

Code: Select all

for _, v in pairs(data.raw["item"]) do
    v.icon = string.gsub(v.icon, "__oldmod__", "__newmod__")
end
Recipes might not have an icon defined and simply inherit the one of their result, but the icon can still be defined in case there are multiple results or e.g. for the different ways to produce solid fuel.

If you put that code in data-final-fixes.lua it'll hopefully run last so the changes will stick around. (If another mod is doing something similar in data-final-fixes.lua and overwriting your changes, add a dependency to it so your mod will be loaded last.)
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3715
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Updating graphics of installed mods

Post by DaveMcW »

prg wrote:If you put that code in data-final-fixes.lua it'll hopefully run last so the changes will stick around. (If another mod is doing something similar in data-final-fixes.lua and overwriting your changes, add a dependency to it so your mod will be loaded last.)
data-updates.lua and data-final-fixes.lua should be avoided whenever possible, it is much better to use data.lua and a dependency.

viewtopic.php?p=127496#p127496
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Updating graphics of installed mods

Post by darkfrei »

In the info file you can write mods what you need. Your mod will be read after them.
Metalface7
Inserter
Inserter
Posts: 28
Joined: Sat Jun 11, 2016 1:49 pm
Contact:

Re: Updating graphics of installed mods

Post by Metalface7 »

In that case, how would I detect if one of the mods is installed (so I can use it in an if/then statement) without having to explicitly state it in a config file?

Additionally, it appears that mods that I have added optional dependencies for are still overriding my icons. Does that mean I am forced to use data-final-fixes.lua to force my changes to be loaded last?
Post Reply

Return to “Modding help”