Is there a guide for item ordering and subgroups?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
bigyihsuan
Filter Inserter
Filter Inserter
Posts: 299
Joined: Thu Jan 01, 2015 12:57 pm
Contact:

Is there a guide for item ordering and subgroups?

Post by bigyihsuan »

The wiki has the unhelpful:
order

Is used to order items in inventory (when sorting is enabled) and to sort recipes in crafting screen.
And the closest thing to a "guide" to item sorting is this post by kovarex from 2 years ago, but it's still pretty confusing.

seronis
Fast Inserter
Fast Inserter
Posts: 225
Joined: Fri Mar 04, 2016 8:04 pm
Contact:

Re: Is there a guide for item ordering and subgroups?

Post by seronis »

This really needs CLEARLY explained by a dev. And the dev needs to have one of their friends WHO HAS NO CODING EXPERIENCE read their description first. Its not useful if the description makes sense to someone who already knows whats going on. Needs to be useful enough of a description to teach.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Is there a guide for item ordering and subgroups?

Post by DaveMcW »

Let's use Steel furnace as an example.

item.lua

Code: Select all

{
  type = "item",
  name = "steel-furnace",
  icon = "__base__/graphics/icons/steel-furnace.png",
  flags = {"goes-to-quickbar"},
  subgroup = "smelting-machine",
  order = "b[steel-furnace]",
  place_result = "steel-furnace",
  stack_size = 50
},
item-groups.lua

Code: Select all

{
  type = "item-group",
  name = "production",
  order = "b",
  inventory_order = "d",
  icon = "__base__/graphics/item-group/production.png"
},
{
  type = "item-subgroup",
  name = "smelting-machine",
  group = "production",
  order = "d",
},
kovarex wrote:the ordering of items is determined by these priorities
  • 1) Item group
  • 2) Item subgroup
  • 3) Item order string
  • 4) Item name
To decode that:
1. Steel furnace is in the "production" group, which is order "b", the second tab.
2. Steel furnace is in the "smelting-machine" subgroup, which is order "d", the fourth row.
3. Steel furnace is order "b", the second item in the row.
4. Let's duplicate the steel furnace, call the new item "stainless-steel-furnace", and also give it order "b". The new item would appear ahead of "steel-furnace" in alphabetical order.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Is there a guide for item ordering and subgroups?

Post by Rseding91 »

seronis wrote:This really needs CLEARLY explained by a dev. And the dev needs to have one of their friends WHO HAS NO CODING EXPERIENCE read their description first. Its not useful if the description makes sense to someone who already knows whats going on. Needs to be useful enough of a description to teach.
You want a programming concept for programmers explained in a non-programmer way - that makes no sense.

Anyone who's going to be changing item ordering, subgroups, and order strings is going to be a programmer and as such explaining it to them as a programmer is exactly what is expected.
If you want to get ahold of me I'm almost always on Discord.

seronis
Fast Inserter
Fast Inserter
Posts: 225
Joined: Fri Mar 04, 2016 8:04 pm
Contact:

Re: Is there a guide for item ordering and subgroups?

Post by seronis »

Well I dont see it as a coding concept at all. Its describing labels and order and the examples are not self explaining. Post prior to yours did a good job in general but it doesnt explain some of the convoluted order strings with sections separated by dashes and brackets.

User avatar
bigyihsuan
Filter Inserter
Filter Inserter
Posts: 299
Joined: Thu Jan 01, 2015 12:57 pm
Contact:

Re: Is there a guide for item ordering and subgroups?

Post by bigyihsuan »

DaveMcW wrote:Let's use Steel furnace as an example.
kovarex wrote:the ordering of items is determined by these priorities
  • 1) Item group
  • 2) Item subgroup
  • 3) Item order string
  • 4) Item name
To decode that:
1. Steel furnace is in the "production" group, which is order "b", the second tab.
2. Steel furnace is in the "smelting-machine" subgroup, which is order "d", the fourth row.
3. Steel furnace is order "b", the second item in the row.
4. Let's duplicate the steel furnace, call the new item "stainless-steel-furnace", and also give it order "b". The new item would appear ahead of "steel-furnace" in alphabetical order.
So it's Tab-Line-Column? What happens when you have more than 26 items to a line?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Is there a guide for item ordering and subgroups?

Post by DaveMcW »

You are not limited to 26 letters, the order can be any string you like. It will be sorted in alphabetical order.

User avatar
bigyihsuan
Filter Inserter
Filter Inserter
Posts: 299
Joined: Thu Jan 01, 2015 12:57 pm
Contact:

Re: Is there a guide for item ordering and subgroups?

Post by bigyihsuan »

DaveMcW wrote:You are not limited to 26 letters, the order can be any string you like. It will be sorted in alphabetical order.
So I could do a[item]-c[red]-d[something] and a[item]-c[green]-d[thing] and it would work? Does it have to be an item that's defined, or can it be any tag I want?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Is there a guide for item ordering and subgroups?

Post by DaveMcW »

The [tags] are optional, not used by the game, and only meant to help modders get the order right. That plan seems to have backfired. :P

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Is there a guide for item ordering and subgroups?

Post by Rseding91 »

DaveMcW wrote:The [tags] are optional, not used by the game, and only meant to help modders get the order right. That plan seems to have backfired. :P
The [tags] thing was extremely confusing of Kovarex to say. They are literal strings - they're compared as such. There's no parsing of the string it's simply C++ std::string < comparison.

So for:

Code: Select all

data.raw["item1"].order = "a-[b]-b[car]"
data.raw["item2"].order = "a-[a]-b[car]"
That will be used in the game via:

Code: Select all

std::string item1.order = "a-[b]-b[car]";
std::string item2.order = "a-[a]-b[car]";

return item1.order < item2.order;
And so the C++ std::string comparison operator says that item1.order is not < item2.order because "a" < "b".


In simple terms: It's pure string alphabetical order comparison. Ignore all the "[...] is ignored" stuff - it's not - it's this: https://en.wikipedia.org/wiki/Lexicographical_order
If you want to get ahold of me I'm almost always on Discord.

seronis
Fast Inserter
Fast Inserter
Posts: 225
Joined: Fri Mar 04, 2016 8:04 pm
Contact:

Re: Is there a guide for item ordering and subgroups?

Post by seronis »

Paraphrased:
Rseding91 wrote: It's pure alphabetical order comparison and nothing is ignored.
Then at some point those strings should probably be changed to something that doesnt look like they have parsed sections. But at least we now have the real explanation (that just happens to not require programming knowledge, just describes order)

Post Reply

Return to “Modding help”