Is there a way to force the ordering of recipes within a section in the workshop display?
It seems the items get grouped by required level, so I attempted to use fractional levels thinking maybe anything negative would work at level 0. Setting some items at level -0.1 and some at -0.2 didn’t seem to do the trick. All other investigations into item alias, file name, etc. were unsuccessful. Am I just stuck with the alphabetical order of the item’s description within each group with the same required level?
How it currently works is that they get grouped by their level and in alphabetical order. The function that orders the recipes can be found in stonehearth/ui/game/show_workshop/show_workshop.js on line 153. If you’re looking to change the order then your best bet is to change that function (if that’s what you’re looking to do then I’d recommend monkey patching it and not overriding the entire file).
How do you want them to be sorted? I assume it’s also by their purpose (e.g. all the doors first, then the windows, then the lanterns, etc.)?
Thanks, @Drotten. Without giving away my super secret mod, your example is very analogous to my dilemma. I’d like to avoid kludges in the item names like “lantern (red)” and “lantern (green)” in order to force things to appear grouped in the UI.
By the way, the reason I had tried the fractional level was that I discovered that does work for re-ordering the sections within the workbench recipe list. While the key “ordinal” suggests and integer, fractional numbers will work. I tried it because I was considering what to put for my numbers. The vanilla Stonehearth carpenter, for example, has 4 sections. I didn’t want to use 5, 6, 7 in my mod, since someone else could do the same thing and then our item sections would end up unpredictably interleaved when both mods are installed. Instead I plan on just picking a big semi-random number for each of my mods like 7643.1, 7643.2, 7643.3, and in my testing this allowed me to successfully order sections titled something akin to “My B Items”, “My A Items”, “My C Items” in the desired order.
I’ll take a look at that js file and see what I can come up with.
So, it turns out fractional level requirements will work, just not as I suspected, and it’s only aesthetically pleasing if you do it for items that are available at level 0.
From looking at the file Drotten pointed me to, a combined tag gets created consisting of required level plus item name, and then those are ordered. When I tried using -0.1 and -0.2 levels, I was creating pseudo-names like “-0.1Item A” and “-0.2Item B” thinking I could make “Item B” come first since it’s level was less. Of course, the “-0.1” part still comes before “-0.2” alphabetically, so my test had no effect. When I take alphabetical order into account instead of numerical it works! But not so fast, it only looks OK because the recipe is unlocked at start. If I try the same approach with another set of items in my mod that are supposed to be unlocked at level 1, the ordering OK, the unlocking works as expected, but I get the unappealing “Unlocked at Level 0.9” in red lettering when I look at the workbench of my newly promoted carpenter.
For any devs who may be seeing this, since you are already reworking crafting, perhaps you might consider adding an “ordinal” property to the recipes in the lists themselves same as there is for the higher level categories. I’m guessing it would be backward compatible since if it defaulted to 0, then everything would behave as it does now if it wasn’t explicitly used.
It’s interesting to know that you could use fractional numbers for that; I didn’t consider it before, but thinking of it it does make sense that you can. I’ll keep that in mind.
Yeah, that’s very off putting. Since you’re keeping your project a secret (which I respect) there’s not much for me to add, but for ordering the recipes it’s only for an aesthetic value right? In that regard I’d say that it’s ok to skip that part go for now and focus on the other features of your mod, and come back to this later when there’s better support for what you want to do.
Having ordinals for each recipe would be handy I’d agree, to add to that I’d like to see options for different sorting methods (by alphabetical, level req, or type). I think it would help especially when there can potentially be hundreds of recipes from various mods (at least there’s a search function).
The desire is just for organizational purposes. I’m adding my own categories, so no need to worry about mixing in with other people’s mods – unless, of course, someone decides to mix into mine. My dilemma is that I have a category that logically has ~20 items, but there are groups of four or pairs within those that make sense to be close to one another.
No worries. I’m a long ways from releasing at this point, anyway…
Resurrecting my own dead thread from last fall to mention that I found a solution to this issue that didn’t require digging into the .js files and coding/extending methods. What I did was to take advantage of the zero-width space character, unicode U+200B. You can insert one or more of this character to force items to be pushed down in the alphabetical order. This is the method I used:
Opened my word processing program and created a three character string “Q” U+200B “Q” (looks like just “QQ” in editors).
Copied the “QQ” from word processor and pasted into my en.json file in my item list in text editor. I had several groups of items in the sub-menu I was working with: first set got no "QQ"s at start of item name string, second set got 1 “QQ”, third set got 2 "QQ"s, etc.
Searched and replaced in my en.json to swap all single “Q” letters with nothing (I didn’t have any “real” capitol Qs in my file, which is why I used that in my helper string for copying).
Repacked my mod and opened Stonehearth to verify it works as expected. Perfect forced ordering with invisible characters that don’t impact the play experience!
Only drawback is the hidden strings in the en.json file that I need to remember in case I ever edit that sub-menu.