Help me out here (and yourself maybe)

Okay so instead of adding or replacing content I had my reasons to get rid of some! :slight_smile:

I never did any modding in Stonehearth but I decided to dive into the files anyways, suprisingly it only took me a minute to accomplish what I wanted. Basically I just had to delete a few lines of codeā€¦

But then I thought, what if I turn this into a ā€˜modā€™ so I could easily turn it on or off, or share it with everyone? And so I set up this folder structure inside the /mods folder:

  • /temp/
    • /manifest.json
    • /handlers/
      • farming_handler.lua

The manifest:

{
   "info": {
      "name": "temp",
      "version": 3
   },
      "override": {
      "stonehearth:call_handlers:farming_call_handler": "temp:handlers:farming_handler"
   }
}

My tweaked version of the ā€˜farming_handlerā€™ is simply missing a few lines of code and Iā€™m trying to replace the original file with this one.

The problem?
It works when I delete the code in the original file, but not as a mod trying to replace it.

Possible solutions I tried:

  • Rebooting the game, several times
  • Removing and adding the ā€˜modā€™ entirely
  • Adding the ā€˜requiredā€™ statement to the manifest, so that it is forced on

because I noticed json being used differently sometimes, I also tried:

  • Swapping the pathā€™s colons for slashes
  • Using ā€˜file()ā€™ instead of the folder name

Interesting is that without the required statement, I noticed the mod turning itself off every time I quit to main menu, or reboot the game. Which is odd behaviour as far as Iā€™m aware.

Try switching this line "override": into "overrides": (add an S at the end).

Also, it seems you are using aliases within your ā€œoverridesā€-call?
Iā€™ve never seen it used that way before - but if it works, make sure both aliases exist (in the Stonehearth manifest and your manifest respectively).

In overrides (and mixintos etc.) I always point to files by folder-structure :slight_smile:

I works with aliases too, but @Nex doesnā€™t have that alias declared in his manifest.

1 Like

Shouldā€™ve noticed this, I changed it, didnā€™t solve the issue though.

This (as pointed by Relys) does not exist. You need to create that alias to use that way, or replace it with the file path.

As far as I know (checking other modsā€™ manifests) the path on the right refers to the ā€˜moddedā€™ content? So therefore the folders and files could be named anything right?

temp:handlers:farming_handler is not equal to temp/handlers/farming_handler.lua
A path has slashes /.
Those with : are aliases to a path.

The right side is what will replace or add to the left side.
The alias is just a shortcut to a path, like this

ā€œyour_mod:your_aliasā€:ā€œfull/path/here/that/you/dont/want/to/type/everytime.jsonā€

The alias creation goes into the alias section, above the overrides, like this:

ā€œaliasesā€{
ā€¦
}

I get what you say but I donā€™t understand yet what Iā€™m doing wrong here.

ā€œtemp:handlers:farming_handlerā€ does exist, because it refers to the folders/files with identical names right?

And also, why would I want to use an alias when this manifest has only 1 reference basically.

Now, this makes sense, I thought those were the same. I did mention in op that I tried both ways though

temp:handlers:farming_handler is not equal to temp/handlers/farming_handler.lua
A path has slashes /.
Those with : are aliases to a path.

You donā€™t need an alias. You are right, but using : means it is an alias. Replace them with / so they are an actual path. Oh, and you will need the file extension too, so add the .lua

So this is correct?
ā€œstonehearth/call_handlers/farming_call_handlerā€: ā€œfile(handlers/farming_handler.lua)ā€

Or should the first part be colons still?
ā€œstonehearth:call_handlers:farming_call_handlerā€: ā€œfile(handlers/farming_handler.lua)ā€

Still not working with either of those.

As pointed out by @Relyss and @BrunoSupremo, you either want to add the alias or point to the files by their respective folder-structure.

An example with folder-structure:

{
   "info": {
      "name": "temp",
      "version": 3
   },
      "overrides": {
      "stonehearth/call_handlers/farming_call_handler.lua": "temp/handlers/farming_handler.lua"
   }
}

If you want to add an alias to your mod, it would look something like this

"info": {},

"aliases" : {
    "handlers:farming_handler": "file(temp/handlers/farming_handler.lua)"
 },

 "overrides": {}

But, as pointed out by @BrunoSupremo, the alias you tried to call in the Stonehearth-mod does not exist in its manifest.

1 Like

The first one needs a .lua. So farming_call_handler.lua. A path is always complete, slashes and file extensions included.

The second is incorrect because there is no aliases named ā€œstonehearth:call_handlers:farming_call_handlerā€.

Just search at the stonehearth manifest to see if an alias exists or not. If not, use the full file path.

The ā€œfile()ā€ method is a path relative to your current file using it.
This is also the only time where you can have a path without a file extension, but only if your file is a json and it has the same name of its folder. So you can stop the path at the folder and it will guess that it has a json file there.
Like ā€œfile(path/entity)ā€ will point to path/entity/entity.json

1 Like

Alright I get it now, even with coding experience this json and lua made no sense to me at first. And before @Hamnisu wrote that example I didnā€™t understand it either.
But thank you all for you time as this is very basic information I suppose. Though still way more difficult than the original change I made to the code itself!

1 Like

Before starting my own mod, I had never worked with JSON nor Lua either - I understand your struggles getting started.
Iā€™m still not very experieced with them.

Itā€™s not ā€œbasic informationā€ until you understand more advanced stuff; so donā€™t beat yourself up over this! :wink:
Glad the issue is solved!