Updating graphics of installed mods

Place to get help with not working mods / modding interface.

Updating graphics of installed mods

Postby Metalface7 » Fri Apr 21, 2017 5:43 am

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!
Metalface7
Inserter
Inserter
 
Posts: 26
Joined: Sat Jun 11, 2016 1:49 pm

Re: Updating graphics of installed mods

Postby prg » Fri Apr 21, 2017 6:43 am

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
prg
Filter Inserter
Filter Inserter
 
Posts: 941
Joined: Mon Jan 19, 2015 12:39 am

Re: Updating graphics of installed mods

Postby DaveMcW » Fri Apr 21, 2017 6:55 am

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
DaveMcW
Smart Inserter
Smart Inserter
 
Posts: 2157
Joined: Tue May 13, 2014 11:06 am

Re: Updating graphics of installed mods

Postby darkfrei » Fri Apr 21, 2017 10:26 am

In the info file you can write mods what you need. Your mod will be read after them.
User avatar
darkfrei
Filter Inserter
Filter Inserter
 
Posts: 662
Joined: Thu Nov 20, 2014 11:11 pm

Re: Updating graphics of installed mods

Postby Metalface7 » Fri Apr 21, 2017 3:48 pm

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?
Metalface7
Inserter
Inserter
 
Posts: 26
Joined: Sat Jun 11, 2016 1:49 pm


Return to Modding help

Who is online

Users browsing this forum: No registered users and 1 guest