[Resolved] Loading different sprite if a mod is detected

Place to get help with not working mods / modding interface.
User avatar
Thomasnotused
Filter Inserter
Filter Inserter
Posts: 263
Joined: Thu Jan 29, 2015 9:58 pm
Contact:

[Resolved] Loading different sprite if a mod is detected

Post by Thomasnotused »

Hello! In an effort to improve compatibility with the Liftoff mod, I'm trying to load a different spritesheet (without the shadows) when it is detected, but I'm unsure about how to do this, would I have to disable the vanilla entities and load a new set with the new sprite?
Last edited by Thomasnotused on Mon Aug 29, 2016 5:42 pm, edited 1 time in total.
I have no idea what I'm doing.
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Loading different sprite if a mod is detected

Post by Adil »

There's no interface for mod detection during data loading. Mostly it is done by making one mod to optionaly depend on other and then check if some mod-specific item is added to data.raw.
Given that data.lua is actually a script to generate data and not static definition, you hen can have conditionals and various complex operations to determine each field in prototype, including its graphics.

Considering the Aircraft and Liftoff, the thing is that the latter already depends on the former. Basically, that's what was in data.lua of liftoff: a few instructions to change the sprites (well, there's other unrelated stuff there). As long as the sprite sheets are somewhere, and their location is known, it is possible to set any prototype graphics to those sheets. The reason that the issue was raised in the mod thread is that I didn't like the idea of bundling heavy but not very different sprites into the scripting mod, which weights a hundred times less without them.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
User avatar
Thomasnotused
Filter Inserter
Filter Inserter
Posts: 263
Joined: Thu Jan 29, 2015 9:58 pm
Contact:

Re: Loading different sprite if a mod is detected

Post by Thomasnotused »

Adil wrote:There's no interface for mod detection during data loading. Mostly it is done by making one mod to optionaly depend on other and then check if some mod-specific item is added to data.raw.
Given that data.lua is actually a script to generate data and not static definition, you hen can have conditionals and various complex operations to determine each field in prototype, including its graphics.

Considering the Aircraft and Liftoff, the thing is that the latter already depends on the former. Basically, that's what was in data.lua of liftoff: a few instructions to change the sprites (well, there's other unrelated stuff there). As long as the sprite sheets are somewhere, and their location is known, it is possible to set any prototype graphics to those sheets. The reason that the issue was raised in the mod thread is that I didn't like the idea of bundling heavy but not very different sprites into the scripting mod, which weights a hundred times less without them.
Ah, thanks for clearing that up!
I have no idea what I'm doing.
Post Reply

Return to “Modding help”