Page 1 of 1

Is there a guide for item ordering and subgroups?

Posted: Sun Apr 24, 2016 3:00 am
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.

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

Posted: Sun Apr 24, 2016 5:09 am
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.

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

Posted: Sun Apr 24, 2016 6:23 am
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.

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

Posted: Sun Apr 24, 2016 7:52 pm
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.

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

Posted: Mon Apr 25, 2016 2:09 am
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.

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

Posted: Mon Apr 25, 2016 3:00 am
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?

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

Posted: Mon Apr 25, 2016 4:08 am
by DaveMcW
You are not limited to 26 letters, the order can be any string you like. It will be sorted in alphabetical order.

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

Posted: Tue Apr 26, 2016 1:21 am
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?

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

Posted: Tue Apr 26, 2016 1:56 am
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

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

Posted: Tue Apr 26, 2016 3:17 am
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

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

Posted: Tue Apr 26, 2016 4:14 am
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)