What is the sprite name for the logistic trash slots?

Place to get help with not working mods / modding interface.
User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 641
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

What is the sprite name for the logistic trash slots?

Post by Gergely »

It is the file "trash-bin.png" from the core graphics. But how do I refer to if I want to add a sprite-button GuiElement with this icon? Possibly without using direct file reference.

Answer:
eradicator wrote:sprite = "utility/trash_bin"
Last edited by Gergely on Thu Feb 01, 2018 12:24 pm, edited 1 time in total.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by bobingabout »

being able to use the icon from an item as a sprite button is a fairly new thing. in this case, you'd need to reference the file directly.


unfortunately, I've noticed when trying to do this, graphics seem to mess up for some reason.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 641
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by Gergely »

And how do I reference a file directly? According to the SpritePath section in concepts, you have to have "file/" in front. But when I try "file/core/graphics/trash-bin.png" or "file/__core__/graphics/trash-bin.png", I get no image. And no errors. How do I properly refer to it? Or, did I do everything right, and it's just the graphics mess you were talking about which makes it completely invisible.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by darkfrei »

Gergely wrote:It is the file "trash-bin.png" from the core graphics. But how do I refer to if I want to add a sprite-button GuiElement with this icon? Possibly without using direct file reference.
Make a new item with this picture as icon, then call this icon by sprite-button. Factorio style!
User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 641
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by Gergely »

darkfrei wrote:Make a new item with this picture as icon, then call this icon by sprite-button. Factorio style!
I want to create a scenario, not a modification of the game. I believe that this sub forum is for discussing questions related to the modding api which is being used by scenarios as well. Your method is a workaround to the problem rather than a solution.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by eradicator »

You should get a text editor with full directory search, makes things a lot easier :). Found this after 2 seconds of searching:

Code: Select all

gui.add{name = k.."_trash_button", type = "sprite-button", sprite = "utility/trash_bin" ....
And just for reference: You can not use a graphics file for gui elements that has not been previously defined as a prototype. As the game needs to load all graphics on startup. (And creating a new item just to use it as a sprite-button is also wrong :P)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Rseding91
Factorio Staff
Factorio Staff
Posts: 16016
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by Rseding91 »

You can reference any of the utility-sprites through the name they use.

The trash icon uses the name "trash_bin" so you'd use "utility/trash_bin".
If you want to get ahold of me I'm almost always on Discord.
User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 641
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by Gergely »

Rseding91 wrote:You can reference any of the utility-sprites through the name they use.
That is really helpful, but where can I find the list of names that go after "utility"?
User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 641
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by Gergely »

Thanks for the help! My scenario is finished. You can find it in my (current) signature and here.

The working answer is edited into the topic header.
Gergely wrote:but where can I find the list of names that go after "utility"?
I still want to find the answer to this one though.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by eradicator »

Gergely wrote:
Rseding91 wrote:You can reference any of the utility-sprites through the name they use.
That is really helpful, but where can I find the list of names that go after "utility"?
Join the cool brigade and get yourself a shiny new text editor with which you can find out yourself! :geek:
\data\core\prototypes\utility-sprites.lua
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Rseding91
Factorio Staff
Factorio Staff
Posts: 16016
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by Rseding91 »

Utility-sprites.lua.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 641
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by Gergely »

Oh finally! I can't believe it took THIS long for someone to finally give a "proper" answer!!

(Also, in the case you were wondering, I use Notepad++ which does have a directory search function. But such function is also available in the builtin Windows 10 search as well.)
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by eradicator »

Gergely wrote:Oh finally! I can't believe it took THIS long for someone to finally give a "proper" answer!!

(Also, in the case you were wondering, I use Notepad++ which does have a directory search function. But such function is also available in the builtin Windows 10 search as well.)
My post actually has the answer too:
eradicator wrote:\data\core\prototypes\utility-sprites.lua
I just think that learning to use directory search is extremely important for any factorio modder. So i formatted the answer in a way that would encourage you to do that.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 641
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by Gergely »

Well, you told me that directory search is the way to go, and to try it out. I received the following result:

Code: Select all

Search "utility/" (5 hits in 3 files)
  Factorio\data\base\scenarios\pvp\pvp.lua (1 hit)
	Line 197:   local bin = gui.add{name = k.."_trash_button", type = "sprite-button", sprite = "utility/trash_bin", tooltip = {"remove-team-tooltip"}}
  Factorio\data\base\scenarios\team-production\team_production.lua (3 hits)
	Line 367:   game.play_sound{path = "utility/research_completed"}
	Line 741:       player.play_sound({path = "utility/game_lost"})
	Line 744:       player.play_sound({path = "utility/game_won"})
  Factorio\data\base\tutorials\construction-robots\control.lua (1 hit)
	Line 607:               sprite = "utility/confirm_slot",
It did not help. Sure, I got the name "utility/trash_bin" out of it,(but you already told me, so nevermind) but this is not a "list" of the utility names. Later, Rseding91 pointed it out that there is a file named "utility-sprites.lua" that is directly responsible for registering every utility sprite. I opened it, and it was gold mine. Took this long, because everyone decided that instead of going a straight forward path, a curved path, such as a "learning curve" is better. This is today's outdated, but still widely used education.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: What is the sprite name for the logistic trash slots?

Post by eradicator »

Gergely wrote:Took this long, because everyone decided that instead of going a straight forward path, a curved path, such as a "learning curve" is better. This is today's outdated, but still widely used education.
Learning is outdated? Huh. I beg to differ.

Also you only did one search. With an unfit term. That's not an error ofc, searching tends to require trying different terms until the desired result is found. So the error is giving up after one search. Try searching for "trash-bin.png", that will lead you directly to utility-sprites.lua. (Searching for "utility" (no slash) would also have hit that file, though with more noise.) And had you learned this skill you wouldn't have had to "wait this long" for someone else to do the searching for you. Which is exactly why i thought it'd be better to motivate you to learn that skill, so you can skip the waiting phase next time.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Post Reply

Return to “Modding help”