Barrel Fluid Icons


Changes the icon for barrel items to more clearly show which fluid is barreled.

Tweaks
3 months ago
1.1 - 2.0
2.59K

b [Fixed] Igrys barrels throwing error

4 months ago
(updated 4 months ago)

Hi there

Found another mod with troublesome barrels :-) https://mods.factorio.com/mod/Igrys

https://github.com/TheTaurunti/factorio-barrelfluidicons/blob/d6e18d44b645c63d57f80fafcfee58c184366228/data-updates.lua#L83 breaks since prototype_base is nil => Factorio exits when your setting "BarrelFluidIcons-fluid-icon-primary" is activated.

See their barrels here:
https://github.com/EgorexW/Igrys/blob/master/Scripts/Items/StrongBarrel.lua

I saw what you did to be compatible with other mods and tried it - when adding igrys-strong-barrel and igrys-strong-barrel-filled-magic-fluid to your NON_FLUID_BARRELS array in data-updates.lua, Factorio launches and it works.

I also looked into another mod I had installed and wondered how they do it - it's the same idea with trying to check the name strings: https://github.com/pla/barreling-group2/blob/main/data-final-fixes.lua, and there it doesn't work for the Igrys barrels, too.

Although, I will say, I have a number of other mods installed, all the others seem to follow the pattern you expect with naming the recipes relevant to your mod. I think I'll file a report at Igrys mod, maybe they can fix it and follow the kinda established convention... although I understand and like their idea of prefixing their items... can't have everything I guess.

Thanks for reading, would be lovely if you could add compatibility (or maybe the Igrys folks rename their barrels, who knows...).

(story time, irrelevant part)
- I made the mistake of thinking "but deciding on the item's name containing the string barrel, that's error-prone, there's got to be a better way, I'm a software engineer, we can do better", and I was in the mood for digging around and thought maybe something good comes out for the community
- After understanding that there's no safe way to identify the items and recipes and consulting ChatGPT whether it has some other ideas, in the end drifting into a philosophical discussion with it about humans and AIs and our perception of the world, meanwhile accepting its observation that I'm "trying to infer intent from data that's not semantically marked" (I love how that's put, credits ChatGPT), coming back after many hours and feeling like this guy https://www.reddit.com/r/ProgrammerHumor/comments/slik5/total_hours_wasted_here/ - may I suggest that you exclude the Igrys barrels, following the same path that you in your wisdom chose for other mods in the first place, and the error should disappear? :-))
(end of story time)

4 months ago

Yep, definitely two points of friction with other mods. 1st is adding barrel-like items such as the strong barrel from igrys or the particle canisters from Space Exploration, second is with not following base game naming convention (less common, as barrel recipes are typically done programmatically)

Will add compatibility for the igrys barrels, and see if some nil checking would be good for this mod. Kudos for finding the solution with NON_FLUID_BARRELS :)

4 months ago

New version is uploaded with compat for igrys

4 months ago
(updated 4 months ago)

perfect, I just saw it! Regrettably, I get the old crash - I reckon you have to tell our poor computers that they should include your new lua file and execute it, otherwise they don't get that it's a fixed problem. :-))

https://github.com/TheTaurunti/factorio-barrelfluidicons/blob/f69b648b02ab57cc3768e95fd5ea77c8b02ba524/data-updates.lua#L47

edit: love your changelog comments, by the way :-)

4 months ago

aha... uhhh... oops

I reuploaded v1.0.6 which now properly invokes the script for Igrys compatibility

4 months ago

yay, works! thanks a lot! :-)

4 months ago
(updated 4 months ago)

Renamed recipe: igrys-strong-barrel-filled-magic-fluid → igrys-magic-fluid-strong-barrel
Renamed recipe: igrys-empty-strong-barrel-filled-magic-fluid → empty-igrys-magic-fluid-strong-barrel
Renamed item: igrys-strong-barrel-filled-magic-fluid → igrys-magic-fluid-strong-barrel

Sorry for the inconvenience, implemented the changes suggested by stef77 into my mod. You should change your compatibility file.

4 months ago

thank you, but that doesn't work it seems, I added some thoughts here... https://mods.factorio.com/mod/Igrys/discussion/68041011481e0aff9a4b0e85

sorry for the confusion, it seems they have to be added to the exclude list here, I don't see a way how to make this work otherwise...

4 months ago

Alright, Taurunti don't change anything for now. Will tell when I sort it out:)

4 months ago
(updated 4 months ago)

Hi, so I took some time to try to understand the issue better. I've posted an update in the other thread at Igrys (https://mods.factorio.com/mod/Igrys/discussion/68041011481e0aff9a4b0e85) and had some ideas what they could do (at least as far as I understood), but there needs to be some compatibility added in Barrel Fluid Icons as well...

So the easiest way would be if you continue to exclude their barrels in your exclusion file, although if Igrys updates the barrel names as suggested, you'd have to update https://github.com/TheTaurunti/factorio-barrelfluidicons/blob/8fb862786277e996144bf111a879501a65f62c74/compatibility/data-updates/Igrys.lua#L3 as well...

But I experimented a bit; I think you could skip the exclusion of their barrels entirely if you add some checks in your code, I sketched that here: https://github.com/TheTaurunti/factorio-barrelfluidicons/pull/1 (no guarantee, seemed to work for me, but I don't know about interactions with other mods). Basically, when you find no recipe or fluid from a barrel (such as the basic strong barrel from Igrys which acts like a vanilla empty barrel), the properties are still nil, and you could then branch and do nothing in this case.

When I included these two checks, there was no need to add the Igrys barrels to NON_FLUID_BARRELS. Might solve this for other mods, too...

Now what's a bit odd is that you expect the resulting fluid of the empty recipe at index position 1: https://github.com/TheTaurunti/factorio-barrelfluidicons/blob/8fb862786277e996144bf111a879501a65f62c74/data-updates.lua#L19

The automagically created vanilla barrels have that at index 1 and apparently lots of other mods, too. Maybe Igrys will switch the array positions as I suggested over there and all will be fine, but I think one could say that you could iterate over the results and pick the first fluid or something like that, so your code would be a bit more robust and could handle cases when the array order is different.

What do you think?

4 months ago

Good ideas and fair points both! I've realized recently that a change was needed to reduce the compatibility additions of this mod (despite being fairly easy to add). The biggest problem was in crashing when unexpected situations occured.

I made a change so that the mod starts from known fluids and known barrel items (or barrel-like items) and checks if combinations of those barrels and fluids exist, and only then tries to do things that would otherwise cause crashes.

As an example of before-and-after for the previously added compats:
1. Dirty Fluid Containers - since the dirty-barrel items are not registered as "known" barrel items, their existence does not affect the mod's execution
2. PyAlienlife - I still think that adding barrels specifically for milk is an odd choice, but now the worst that will happen is this mod will see if milk can be put in normal barrels (it cannot) and it will not do anything further.
3. Igrys - Will not crash regardless of what the mod author decides for strong-barrel naming conventions. At the moment, the fluid icon does not show up on the filled barrel item (I may add code to do this at a later point). Luckily, that particular barrel is very visually distinct.

4 months ago

Seems to work fine now, thanks a lot! :-)

3 months ago

I am still getting an error:

4.858 Error ModManager.cpp:1758: Error while loading item prototype "igrys-magic-fluid-barrel" (item): Key "icon" not found in property tree at ROOT.item.igrys-magic-fluid-barrel
Modifications: Igrys › Barrel Fluid Icons

Using Igrys 1.5.0 and BFI 1.0.8

3 months ago

Same. For now, downgrade the version. ther it works

3 months ago

Uploaded a new version, should work OK. The igrys magic fluid will be ignored by this mod

3 months ago

And by doing so, all barrels are gone. (^_^")
Downgraded back to 1.0.7

3 months ago

Updated which actually will skip igrys fluid now

There was no issue I could find with all barrels being gone Ogrum.
If you have that error after the newest version please let me know

New response