Order

Place to get help with not working mods / modding interface.
Post Reply
MineGame159
Inserter
Inserter
Posts: 38
Joined: Sun Apr 16, 2017 1:54 pm
Contact:

Order

Post by MineGame159 »

I want to display my item-group last but I dont understand how order works. How is it done? Whats the a, b, ... letters?

Bilka
Factorio Staff
Factorio Staff
Posts: 2853
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Order

Post by Bilka »

The order property is a simple string. When the game compares 2 like prototypes if the order strings aren't equal they're lexicographically compared to determine if a given prototype comes before or after another. Overall, this results in an alphabetical order.

https://wiki.factorio.com/Types/Order
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

MineGame159
Inserter
Inserter
Posts: 38
Joined: Sun Apr 16, 2017 1:54 pm
Contact:

Re: Order

Post by MineGame159 »

Bilka wrote:The order property is a simple string. When the game compares 2 like prototypes if the order strings aren't equal they're lexicographically compared to determine if a given prototype comes before or after another. Overall, this results in an alphabetical order.

https://wiki.factorio.com/Types/Order
I dont know if I am stupid but I dont get it. I am just randomly trying letters to get it work. I think there is lack of documentation for it.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5202
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Order

Post by eradicator »

MineGame159 wrote: I dont know if I am stupid but I dont get it.
He's saying that the order string is just "a string". There's nothing special about it. Neither the letters nor the brackets or hypens have any special meaning whatsoever.

aaa
aab
aab-[aaa]
aab-[aab]

So if you want to be last in the order you have to start with a letter that is "after" all the other letters already used. The highest base game item-group value seems to be "f", so use "g" or "h" or something.
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.

MineGame159
Inserter
Inserter
Posts: 38
Joined: Sun Apr 16, 2017 1:54 pm
Contact:

Re: Order

Post by MineGame159 »

eradicator wrote:
MineGame159 wrote: I dont know if I am stupid but I dont get it.
He's saying that the order string is just "a string". There's nothing special about it. Neither the letters nor the brackets or hypens have any special meaning whatsoever.

aaa
aab
aab-[aaa]
aab-[aab]

So if you want to be last in the order you have to start with a letter that is "after" all the other letters already used. The highest base game item-group value seems to be "f", so use "g" or "h" or something.
So every prototype had some order letter and then based of that letter it is alphabrtical order. Thanks for explanation. I think that is better than what is on wiki because wiki says nothing.

Bilka
Factorio Staff
Factorio Staff
Posts: 2853
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Order

Post by Bilka »

MineGame159 wrote: So every prototype had some order letter and then based of that letter it is alphabrtical order. Thanks for explanation. I think that is better than what is on wiki because wiki says nothing.
Bilka wrote: Overall, this results in an alphabetical order.
I'm sorry if I'm being dense, but how is what I said "nothing"?
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5202
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Order

Post by eradicator »

@Bilka:

I think the wiki article is lacking an explicit comment that none of the non-letters, i.e. mostly "-" and "[" have any special meaning for sorting. The linked wikipedia article is also one of those typical articles written for people who already know roughtly what it's about.

I.e. both your wiki article and the wiki article feel like they're aimed at advanced users, and lack guidance for beginners.

I think this is one of the "general cricisicms" i wrote down...way back...in some other topic. The fact that the wiki articles have no clear target-user structure. Some of them are filled to the brim with examples for beginners. Others (like this one) are condensed down to the minimum, which is nice for advanced users who just want to know the specifics (the group i consider myself part of), but isn't verbose enough for beginners to understand.
Personally i'd find it nice if those two target audiences were seperated. I.e. by having a "technical abstract" on the top of each article for advanced readers. Followed by the verbose explanation with examples for less experienced readers. (But ofc that would require a prohibitive amount of time to change.)

I don't know if there's an english word for "Berufsblindheit", a translation forum suggests "professional tunnel vision". I.e. you might be overestimating the programming-related knowledge of modding beginners, due to your own knowledge being "too advanced". Some modders here on the forums haven't even finished school ;).

(Excuse me if any of the above sounds like a personal attack. It's supposed to be a neutral observation. But i know people often misunderstand that intention when i write things down.)
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.

MineGame159
Inserter
Inserter
Posts: 38
Joined: Sun Apr 16, 2017 1:54 pm
Contact:

Re: Order

Post by MineGame159 »

Bilka wrote:
MineGame159 wrote: So every prototype had some order letter and then based of that letter it is alphabrtical order. Thanks for explanation. I think that is better than what is on wiki because wiki says nothing.
Bilka wrote: Overall, this results in an alphabetical order.
I'm sorry if I'm being dense, but how is what I said "nothing"?
Imagine if you were beginner and you are reading that wiki page about order string will you understand it? Ok there is example but it just first: "a-d" and second: "a-b" and its saying that second will be shown before first but no explain. I dont want to judge you but its very "beginner-unfriendly". All that "-", "[]" its just being confusing for beginners.

Bilka
Factorio Staff
Factorio Staff
Posts: 2853
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Order

Post by Bilka »

eradicator wrote:Personally i'd find it nice if those two target audiences were seperated. I.e. by having a "technical abstract" on the top of each article for advanced readers. Followed by the verbose explanation with examples for less experienced readers. (But ofc that would require a prohibitive amount of time to change.)
I modifed https://wiki.factorio.com/Types/Order to do something like that, please tell me if the page is more understandable now.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

MineGame159
Inserter
Inserter
Posts: 38
Joined: Sun Apr 16, 2017 1:54 pm
Contact:

Re: Order

Post by MineGame159 »

Bilka wrote:I modifed https://wiki.factorio.com/Types/Order to do something like that, please tell me if the page is more understandable now.
Much better now.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2897
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Order

Post by darkfrei »

How to make it parametrically?

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Order

Post by daniel34 »

darkfrei wrote:How to make it parametrically?
?

The order string is just that, a simple string.
- (minus) and [] (square brackets) are just added for human readability, but they don't influence the result*.
I'm not sure what you mean by parametrically/parametrisch.

* They do, somewhat, but you'll probably never get into any situation where it matters, so I'll just refer to https://wiki.factorio.com/Types/Order for further reading (ASCII/UTF8 sorting order and that kind of stuff).
quick links: log file | graphical issues | wiki

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5202
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Order

Post by eradicator »

@Bilka: Yes. Looks much nicer now. My brain is trying to decide if it would be better to write "a" to "z" instead of "a" <linebreak> "z", but i can't really say i like either version better. More importantly my brain still has problems parsing the grammar of the first sentence in "advanced":
When the game compares 2 like prototypes if the order strings aren't equal[...]
I guess that it means "prototypes of the same type", but either the sentence has broken grammar, or my brain has broken grammar parsing :D.

Also the list of sorting order is really nice. I never knew the exact sort order of - and [], but the list should make it pretty clear that there really is no special meaning to them :).
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.

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Order

Post by daniel34 »

eradicator wrote:...
Bilka is German and this is a simple translation error. "2 like prototypes" essentially means "2 similar prototypes" (or technically prototypes that have the same type, which should be reflected on the wiki page). Also, "to determine if a given prototype comes before or after another", comes is reserved for people, the word should be occurs or the sentence should be rewritten.
quick links: log file | graphical issues | wiki

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2897
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Order

Post by darkfrei »

daniel34 wrote:
darkfrei wrote:How to make it parametrically?
I'm not sure what you mean by parametrically/parametrisch.
I mean by the "parametrically/parametrisch" some code, when you make new items on the already existing items/fluids.

For example, when I have some fluids like "water" or "crude-oil", then I can make new items like "barreled-water" and "barreled-crude oil". Some mods can also add new items/fluids to the game and my mod must work with all of them and add to this new items the right order.

Bilka
Factorio Staff
Factorio Staff
Posts: 2853
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Order

Post by Bilka »

daniel34 wrote:Bilka is German and this is a simple translation error. "2 like prototypes" essentially means "2 similar prototypes" (or technically prototypes that have the same type, which should be reflected on the wiki page). Also, "to determine if a given prototype comes before or after another", comes is reserved for people, the word should be occurs or the sentence should be rewritten.
Funnily enough, that sentence is nearly the same as what Rseding wrote when he first made the page, including the two things pointed out here. Though I could see myself making those mistakes :P
updated page wrote:When the game compares 2 prototypes (of the same type) if the order strings aren't equal they're lexicographically compared to determine if a given prototype is shown before or after another.
That should be better :)
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Order

Post by daniel34 »

The wiki still has this entry (under Basic):
So, something with the order "a" comes before something with the order "b" or "c".
"something" is not defined, but it's apparent that it means Prototype. As for "comes", in this case I would say "it is processed/listed before ...".
The order property is a simple string. When the game needs to sort prototypes, it looks at their order properties and sorts those alphabetically. A prototype with an order string of "a" will be listed before other prototypes with order string "b" or "c". The "-" or "[]" structures that can be found in vanilla order strings do not have any special meaning.
EDIT: I already updated the wiki :), feel free to edit/undo the changes if they are not satisfactory.
quick links: log file | graphical issues | wiki

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5202
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Order

Post by eradicator »

daniel34 wrote:
eradicator wrote:...
Bilka is German and this is a simple translation error.
So am i btw. Thus it might have just been some irregular usecase/grammar that i don't know. Which is why i asked. (And i wasn't sure what Bilkas native language is.)

Btw, from a writing-aesthetic viewpoint i firmly remember my teacher being very strict about "numbers smaller than 10 must be written as words". So the whole "2 prototypes" thing always makes me cringe a little (i.e. instead of "two prototypes"). Is that really just me?

Let's look further:
Using a UTF-8 character list, the sort order of special characters can identified, here the sort order for common characters:
is missing auxiliary verbs (and other fixes that are hopefully correct):
Using an UTF-8 character list, the sorting order of special characters can be identified. This is the sort order for common characters:
@darkfrei:
Just use the old order string as a pre/postfix for your new stuff. i.e. order = "newstuff"..old_order.."newstuff"
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.

Bilka
Factorio Staff
Factorio Staff
Posts: 2853
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Order

Post by Bilka »

eradicator wrote: Btw, from a writing-aesthetic viewpoint i firmly remember my teacher being very strict about "numbers smaller than 10 must be written as words". So the whole "2 prototypes" thing always makes me cringe a little (i.e. instead of "two prototypes"). Is that really just me?
I thought I fixed that! The German rules is words for under 13 afaik, no idea about the English rule.
eradicator wrote:
Using a UTF-8 character list, the sort order of special characters can identified, here the sort order for common characters:
is missing auxiliary verbs (and other fixes that are hopefully correct):
Using an UTF-8 character list, the sorting order of special characters can be identified. This is the sort order for common characters:
Google tells me it should be "sort order", so I'll keep that, the other things have been fixed.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5202
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Order

Post by eradicator »

Let's do some more nitpicking while we're at it. (And if any native english speaker finds a mistake i'll be greatful for any corrections.)
When the order strings are equal the game then falls back to comparing the prototype names to determine order.
If the order strings are equal (then) the game then falls back to comparing the prototype names to determine order.
Reason:
If-then (Falls-dann) is used for situations where the occurance of the event is uncertain.
When (Wenn) is used to indicate temporal order of occurance for events that are certain to happen.
Examples using the above ordering:
Missing pural.
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”