Mod coding help?

So I’m trying to figure out how to create a mod that simply adds more building templates to the game. However, I have to do it through code because the buildings I’m wanting to add are going to have the same basic styles that the currently existing buildings have, and creating such buildings through the in-game template creator doesn’t work quite that well because the building vision doesn’t allow me to actually see through all of the roofs/walls that are there because some walls are “patch walls”, I can’t edit the height of columns in-game, and I can’t get the roof(s) to fit properly because the walls aren’t connected in normal rectangles such as

XXXXXXXXXX
X        X
X        X
X        X
XXXXXXXXXX

and instead look like:

 XXXXXXXXXXX
 X         X
XX         XX
X           XXXXXXXXXXXXXXXX
X           X              X
X           X              X
X           X              X
X           X              
XX         XX
 X         X
 XXXXXXXXXXX
/* this is the layout of the walls/columns for the carpenter house that already exists
in-game. I know it looks kind of weird here thanks to spaces between the lines of
characters, but I don't know how to fix that; sorry. */

So…if anyone can help me understand exactly how to create a mod that does this kind of thing (either explain it to me or direct me to some kind of working tutorial), or at the very least explain to me how the organization of the json files for building templates works, then it would be much appreciated. Thanks a bunch!

Well i dont know for the scripting but i do know that if you use slabs you can build brick by brick. The trick with doors and windows is to just leave the exact space open for the windows and stuff. You can then place them with placement mode just how you would place other furniture.

I have not tried saving the building after placing the doors and stuff but i will test it for you if you are not doing that before me xD

hope this helps at least a bit even tho it is not what you are looking for!

I don’t think anyone has ever tried to mod buildings the way you say (well, there have been people that delved into templates, but never made a whole building, especially if the structure changed over alphas). There’s no explanation on those files anywhere as far as I know, because you are supposed to make them by using the building editor.

The building editor will be revamped in the future, to provide better usability and review the current restrictions that displease most of the users.

That said, if you want to understand the building templates files, you can try to create basic small templates and try to correspond the values you see in the file with what you actually made (for example, a single wall).

My guess is that modifying templates files manually would end up breaking them very easily (sometimes not having any effect at all?). Even with just a single wall (2 columns plus the wall) there’s already a lot of data inside the file (don’t know how the IDs are being generated). It also doesn’t guarantee that the hearthlings will be able to build it later.

You can create a mod that adds custom templates very easily, but the easiest and fastest way to create the templates is through the editor.

Edit: As @Yangzhoui suggests, using the slab tool gives you some kind of freedom but I don’t know if it solves your specific problem.

1 Like

@Relyss: Yeah I looked around in the template files, and even tried going piece by piece to figure out how it works. However, looking at stuff like the “shape” values inside the files confuses me because I can’t see how the min and max (x,y,z) values in the files correspond to making a shape. x.x;
If I may make a suggestion (and don’t worry, this would be far off in the future once the game itself is actually a completely finished product), what about offering a special program for modding? Or at the very least, having documentation in the json files that the game uses, that way it would be easier for modders to create new json files that may be necessary for their mod.

@Yangzhoui: Yeah I had a custom template for a “weaver house” building (kind of along the same lines as the carpenter house), but when I tried using the in-game “building vision” feature (which lets you see through the walls and roofs of buildings to be able to look inside), it wouldn’t make the roof see-through, nor would it make all of the walls see-through, as it only works for roofs and walls, and I had to use the slabs to go brick by brick in order to make it look the way I wanted it to. x.x;

1 Like

There’s this tool available: GitHub - stonehearth/stonehearth-editor: A Stonehearth editing tool for modders.
(you can compile it if you have Visual Studio)

But it has some issues and still lacks several functionalities. It helps with cloning and localization.
I have a long term task to write better modding documentation but as the engine keeps changing it has less priority; I’m focusing more on bugs and regression tests at the moment.

There are the GitHub - stonehearth/startermod_basic: A most basic starter mod to get you going! and GitHub - stonehearth/startermod_items: a sample mod showing how to create different types of items for getting started but the tutorials out there are getting outdated so it is always better to observe and copy what is on the latest version of the game.

If you use the slice tool instead it will work since it is counted as floor/ground so you will see trough the building that way ^¢^

I was going to test this myself, but never ended trying it for real.
I think you can create a new wall “brush” with no blocks in it. You know, we have some wall patterns, like some wood stripes or those cool stone blocks, that we can chose from when raising the walls.
Those can be edited (or added as new ones). The files are basically a voxel model of the wall, and the game just copies it, maybe if you create an empty model, you could have some build like the carpenter workshop where one wall is open, and still works in x-ray modes and still be able to put a roof on… Maybe…

Yep, it worked.

I created a wall model “bars” and placed it, the walls have holes in it now and can have a roof.

And x-ray vision works.

…Nevermind, it gives errors when building… :sweat:

And they consider it a solid wall, not going through the holes.

2 Likes