Mod load order, could we get it?

@max99x would there be any chance of an up/down arrow in the mods overview so we can order the mods in there, and have the game load them in the order they are there? would help a lot with mod compatabillity issues.

then a secondary want/need would be some way of being able detect if another mod is on or off so one could anticipate for it a bit more.
(for instance i want to add the option to make beer and later mead in my mod. but dont want to make my mod dependant on stonehearth caffe and its drink-system. but i also dont want to make it clash with said system.

so the prefered way would be a sort of
IF also installed stonehearth caffe: be a drink. if not: be a food that looks like beer.
something like that.
but for that the load order would be required, because if mine would be loaded before the caffe: ofcoarse it would not see the caffe.

(seeing as we are slowly aproaching the age of mod-content rivalling in game amounts of content, this quality of life change might make things more “harmoneous”)

4 Likes

In the explicit example of the cafe mod, there is no harm in making your item a drink too.
In the Archipelago, coconuts are also drink. If you have cafe, they will use those to hydrate, if you do not have, it will be used just as food.

3 Likes

I’ll take a look at how you did your coconuts then :stuck_out_tongue:

You just add the drink component from the cafe mod. It the mod is active it will read that form your json, if not noone will read and it will be ignored

There’s a way to enforce partial mod order (I don’t remember the exact method - @ayazar, @morgan10e, or @linda may be able to help you), but in general, that should be the last resort. You can generally just author your mods such that they are compatible. You do sometimes need to do things in Lua for this. E.g. you can test for the existence of mods by trying to load a JSON file for a URI from that mod, check whether the result isn’t nil, and run different code based on that.

There are certain restrictions though when it comes to mixintos, which cannot be handled by lua (without monkey patching the service). Prime example would be that stonehearth defines a dictionary of some sort ({ "id": { "value": 500 } }), with mod_a modifying it with a mixinto ({ "id": { "value": 1000 } }) and then mod_b saying “You’re not allowed to have that at all”, and removing the pair.

Depending on the mod loading order, you can get all sorts of funky results. If there was a way to do mod ordering (e.g. the way Factorio does it, with optional and required dependencies), this could be solved by mod_b declaring an optional dependency on mod_a.

I mean, I suppose it might be possible to use lua to check for modifications and try to hot-load the changes that really need to be applied last (i.e. always hotloading them, as that is (likely?) always the last mod to run), but that only works for 1 layer. As soon as multiple mods try to do that, chaos ensues again - although it could be sorted with a proper, lua-based ordering perhaps.

1 Like

In stonehearth.json (which lives in stonehearth_data), you can optionally specify the mod load order. By default the list only contains radiant and stonehearth. Any enabled mods you don’t add to that list will be loaded after those in the mod_order list in some arbitrary (but consistent) order.

TLDR: Look in stonehearth.json in stonehearth_data :slight_smile:

2 Likes

Well that’s nifty, and - exactly- what I was looking for!

But… No one could use it I think?
Say game loads mod a, and then mod b does a mix in to change that file and the load order… What would happen? Would it just re load mod a when it hits a in that new list?

Unless there is a way to load a certain mod first and that would have to be a sort of “ideal load order list” you’d get that mod loader program skyrim has situations

This file is meant to be modified manually by the players, it’s not something that you should/can modify via mods.

It has some default configurations from the game but normally nobody need to change it.

1 Like

Eh, in the worst case scenario at least manual load orders are possible then.

Edit: could even put a sort of batch file in your mod that checks out what’s in that list, dump yours before or after what it needs to be, so it’s all automated, well beyond running that file once

2 Likes

According to the strings in en.json of stonehearth.smod, the function of adjusting mod order seems to be on the way.

Don’t take those strings too seriously.

As a translator, I do see strings come and go, but there is still a silver lining, right? :joy:

1 Like

Perhaps related to this, one of my mods seems to be loading before the Stonehearth “mod” finishes loading. I’m trying to do App.StonehearthTeamCrafterView.reopen({...}); but App.StonehearthTeamCrafterView is undefined. Surely the classes in Stonehearth should be defined before other mods start loading?

It works fine with my UnitFramePlus mod, but is that a fluke? Or are the mods (and different parts of the Stonehearth mod) being loaded in alphabetical order and I need to name my workshop mod something that’s later alphabetically than show_workshop? Because that’s the biggest difference I can think of between these two.

This is what I had to do to get my mod to load:

$(document).ready(function () {
    Ember.run.later(this, function () {
        App.StonehearthTeamCrafterView.reopen({
            
        });
    }, 1000);
});

I can only assume that the loading process is multi-threaded and that all of the Stonehearth components are instructed to load before any mods, but the game doesn’t wait for them to finish loading before it starts loading mods. Thus, most views finish loading quickly as it goes along, but a large/complex view like StonehearthTeamCrafterView hasn’t finished loading by the time my mod is loaded, so it’s not defined when I go to reopen it.

Edit: And this strategy only works because I’m reopening a view that isn’t being displayed right from the start. Imagine trying to modify the “start menu” bar at the bottom or something.

1 Like