Page 1 of 1

What is the sprite name for the logistic trash slots?

Posted: Wed Jan 31, 2018 2:55 pm
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"

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

Posted: Wed Jan 31, 2018 3:04 pm
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.

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

Posted: Wed Jan 31, 2018 3:23 pm
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.

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

Posted: Wed Jan 31, 2018 4:24 pm
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!

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

Posted: Wed Jan 31, 2018 8:54 pm
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.

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

Posted: Wed Jan 31, 2018 9:07 pm
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)

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

Posted: Wed Jan 31, 2018 11:13 pm
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".

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

Posted: Thu Feb 01, 2018 9:59 am
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"?

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

Posted: Thu Feb 01, 2018 1:03 pm
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.

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

Posted: Thu Feb 01, 2018 2:10 pm
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

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

Posted: Thu Feb 01, 2018 5:23 pm
by Rseding91
Utility-sprites.lua.

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

Posted: Thu Feb 01, 2018 10:19 pm
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.)

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

Posted: Fri Feb 02, 2018 7:05 am
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.

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

Posted: Fri Feb 02, 2018 4:42 pm
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.

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

Posted: Fri Feb 02, 2018 10:28 pm
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.