Using prototype:Order to sort Blueprints in Inventory

Place to get help with not working mods / modding interface.
Post Reply
guy smiley
Burner Inserter
Burner Inserter
Posts: 13
Joined: Mon Aug 21, 2017 7:40 am
Contact:

Using prototype:Order to sort Blueprints in Inventory

Post by guy smiley »

Hi, so, I'm attempting to change the order of the blueprints and similar items in inventory. As in, how they are sorted within the player's inventory. Currently, I'm using lines like these below, but whilst they compile fine and the game loads them just fine, nothing about the ordering of the items in question changes whatsoever.

Code: Select all

--blueprints and books put at top of inventory - maybe anyway
data.raw["blueprint"]["blueprint"].order = 							"0"
data.raw["blueprint-book"]["blueprint-book"].order = 				"0"
data.raw["deconstruction-item"]["deconstruction-planner"].order = 	"0"
data.raw["upgrade-item"]["upgrade-planner"].order = 				"0"

-- since the above 4 are subgroup "tool" in item.lua & demo-item.lua, trying this also
data.raw["item-subgroup"]["tool"].order = 							"0"
Note: I've used many, many variations on things like "a", "A", "0", "aa", "a-a", etc etc etc, that is just the latest one I tried.

My theory is either some other stage of the prototype heirarchy has precedence regarding item order, or, hmm, I dunno, I guess I have no other theories. Oh, right, the other theory is that I dunno what I'm doing.

Regardless, if there's something fundamentally wrong with my code up above, or with my understanding of how 'order' is supposed to work, or if you have suggestions, please let me know.

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

Re: Using prototype:Order to sort Blueprints in Inventory

Post by eradicator »

https://wiki.factorio.com/Types/Order
The Wiki wrote:If the order strings are equal then the game falls back to comparing the prototype names to determine order.
If you want to decide the order for yourself then you need to assign a different order string to each item.
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: 3128
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Using prototype:Order to sort Blueprints in Inventory

Post by Bilka »

Furthermore, in the inventory, items are first sorted by group (which are sorted by their order), then subgroup (which are sorted by their order), then 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.

guy smiley
Burner Inserter
Burner Inserter
Posts: 13
Joined: Mon Aug 21, 2017 7:40 am
Contact:

Re: Using prototype:Order to sort Blueprints in Inventory

Post by guy smiley »

Well, regarding them having the same string, as I said, no string I tried was doing anything yet. As in, they were not changing order relative to the rest of the inventory either. Once I got something working, then maybe I would have bothered sorting blueprints before reds. Maybe, but that was never my goal - I wanted to put all of them at the start of the inventory, together. So, chances are, I will have them with the same order string once I get it working anyway.

Enough about that, though, I guess I need to change the group's order, then, ty. How do I know what group something is in? The item.lua and demo-item.lua files have subgroup properties specified, but nothing about group. Unless the item files call it something else?

Ah, is that the "item-group" type entries from "demo-item-groups.lua" ?

guy smiley
Burner Inserter
Burner Inserter
Posts: 13
Joined: Mon Aug 21, 2017 7:40 am
Contact:

Re: Using prototype:Order to sort Blueprints in Inventory

Post by guy smiley »

Bilka wrote:
Fri Oct 04, 2019 10:21 am
items are first sorted by group (which are sorted by their order), then subgroup (which are sorted by their order), then order.
Can anyone edit the wiki? Cos that kind of information would be great on the wiki page for order, that sort of specificity about the whole process is completely lacking.

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

Re: Using prototype:Order to sort Blueprints in Inventory

Post by Bilka »

guy smiley wrote:
Fri Oct 04, 2019 2:09 pm
Bilka wrote:
Fri Oct 04, 2019 10:21 am
items are first sorted by group (which are sorted by their order), then subgroup (which are sorted by their order), then order.
Can anyone edit the wiki? Cos that kind of information would be great on the wiki page for order, that sort of specificity about the whole process is completely lacking.
Anyone can edit the wiki, yes :p Good luck making a statement specific to items on a page about a general type/general prototypes, though. I'm open to suggestions of where to document the behaviour.
Enough about that, though, I guess I need to change the group's order, then, ty. How do I know what group something is in? The item.lua and demo-item.lua files have subgroup properties specified, but nothing about group. Unless the item files call it something else?

Ah, is that the "item-group" type entries from "demo-item-groups.lua" ?
The item group is derived from the item subgroup. So, the easiest change would be to make a new item group and subgroup, put those at the front, and put the item in there.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

guy smiley
Burner Inserter
Burner Inserter
Posts: 13
Joined: Mon Aug 21, 2017 7:40 am
Contact:

Re: Using prototype:Order to sort Blueprints in Inventory

Post by guy smiley »

That is what I ended up doing, yes. Yeah, I dunno how or when I'll edit that stuff in, now I get to learn how to edit a wiki as well I guess :p, but if I get my own stuff working it may or may not be soon.

Edit: Oh, yep, worked like a charm, first time :) ty guys for all the help. And gals if appropriate.

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

Re: Using prototype:Order to sort Blueprints in Inventory

Post by eradicator »

Protip for future readers of this post who don't want to enforce their own prefered order on all the others ppl in a multiplayer game: You can just use inventory filters to move the blueprints to the beginning. Though you'll either temporarily have to disable inventory sorting or make your inventory empty because you can only arbitarary filters on empty slots (for filled slots you can only set the filter to the current item).
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
mat1k
Long Handed Inserter
Long Handed Inserter
Posts: 55
Joined: Sat Dec 22, 2018 8:48 am
Contact:

Re: Using prototype:Order to sort Blueprints in Inventory

Post by mat1k »

guy smiley wrote:
Fri Oct 04, 2019 2:32 pm
That is what I ended up doing, yes. Yeah, I dunno how or when I'll edit that stuff in, now I get to learn how to edit a wiki as well I guess :p, but if I get my own stuff working it may or may not be soon.

Edit: Oh, yep, worked like a charm, first time :) ty guys for all the help. And gals if appropriate.
You don't need to learn how to edit the wiki. If you can figure out an ideal place for it to go, then Bilka will most likely be happy to add it in. Bilka is the admin who takes care of the wiki.

Post Reply

Return to “Modding help”