Page 1 of 1

mod-defined utility-sprite not recognized

Posted: Sun Nov 29, 2020 10:35 pm
by ixu
In data.lua:

Code: Select all

data.raw["utility-sprites"].default.factorio = 
{
    filename = "__core__/graphics/factorio-icon.png",
    priority = "medium",
    size = 64,
    scale = 0.5,
    flags = {"icon"}
}

I want to use that sprite in some gui-field as caption:

Code: Select all

myframe.caption = "[img=utility/factorio]"
But it only shows "[ img=utility/factorio ]" (without the spaces) instead of the factorio-icon

Re: mod-defined utility-sprite not recognized

Posted: Sun Nov 29, 2020 11:26 pm
by Deadlock989
You can't add new utility sprites. You can only change existing ones.

But you can just create a new sprite prototype and then use it in rich text.

Code: Select all

    {
        type = "sprite",
        name = "fuel-icon-red",
        filename = "whatever",
        priority = "extra-high",
        width = 64,
        height = 64,
        mipmap_count = 4,
    }

Code: Select all

[img=fuel-icon-red]

Re: mod-defined utility-sprite not recognized

Posted: Mon Nov 30, 2020 12:36 am
by ixu
Thanks.
But I did not found this fact in the documentation or the wiki. Should be updated there.

Re: mod-defined utility-sprite not recognized

Posted: Mon Nov 30, 2020 12:39 am
by Deadlock989
ixu wrote: Mon Nov 30, 2020 12:36 am Thanks.
But I did not found this fact in the documentation or the wiki. Should be updated there.
Anyone can become a wiki contributor.

Re: mod-defined utility-sprite not recognized

Posted: Mon Nov 30, 2020 12:54 am
by ixu
Sure, I will do this tomorrow. But the Factorio-docu needs update too:

https://lua-api.factorio.com/latest/Con ... SpritePath

Re: mod-defined utility-sprite not recognized

Posted: Mon Nov 30, 2020 1:44 am
by Deadlock989
No, it says so. If it makes you feel better, I also missed it the first time I did this kind of thing. But it's right there.

Untitled.jpg
Untitled.jpg (88.54 KiB) Viewed 1508 times