Page 1 of 1
Updating graphics of installed mods
Posted: Fri Apr 21, 2017 5:43 am
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!
Re: Updating graphics of installed mods
Posted: Fri Apr 21, 2017 6:43 am
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.)
Re: Updating graphics of installed mods
Posted: Fri Apr 21, 2017 6:55 am
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
Re: Updating graphics of installed mods
Posted: Fri Apr 21, 2017 10:26 am
by darkfrei
In the info file you can write mods what you need. Your mod will be read after them.
Re: Updating graphics of installed mods
Posted: Fri Apr 21, 2017 3:48 pm
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?