Modding Stonehearth's Graphics Test Program

Awesome, you need some serious scaffolding to build those big towers too. :smiley:

@Xavion Nice papa rabbit.

1 Like

Oh I know that much, what I want to figure out is how it determines which colours to use where. All these references to _radiant.csg are throwing me off though as I can’t find the source, I’m starting to suspect that it’s engine api stuff without api in lua but I’ve still got a few things to try first.

Actually to anyone who wants to try it here is a modified start_game.luac, to add new entities make a folder for them in the entities folder somewhere and add them to manifest.json. Contains an extra function to allow modifying the terrain as well, for reference the grass and the dirt are two separate cubes which are in fact just rectangular prisms with coordinates for the corners given.

It was pointed out to me the the file as is will crash the graphics test, this is because it references the big_rabbit entity which you won’t have. Just deleting or commenting out those lines should fix it.

@LunarWolf @Xavion That was the last thing i thought about haha. Now when im back home im going to mod the game. Maybe i will have a look into controlling the workers seems like most of the function are inside but they get never called. I wish everyone Happy Modding :wink:

Dang, you leave for a few hours and people are place entire towns into the damn thing. I wish I could do what you did. But I don’t have the full version of Qubicle Constructor. I’m still holding out for the special version that will be made for SH.

Can someone write up a quick How To on how they are able to put other assists in to the Test? I’m not sure I understand. How did you change the .lua files and then compile them?

1 Like

To replace the models just replace the .qb files. To add entities make a new folder and follow the format of the current ones along with adding it to manifest.json. To change the lua files you can use the zip I posted a bit back however not all of the lua files turned out valid so just copy the ones you need over to replace the corresponding files.

Here you go made the terrain bigger :slight_smile: :

And here with more trees and an increased rabbit population:


Thank you for the help. It’s good to know how to do it on this level.

excellent work! :+1:

i think they’re capable of doing that themselves… :blush:


@SteveAdamo Thanks :wink:

I have also build a house made of DIRT_ROAD:

For everyone who is interested here the lua code for the house:

      --House first stage
  r3:add_cube(Cube3(Point3(90, 1, 90), Point3(91, 2, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 1, 90), Point3(100, 2, 91), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(99, 1, 91), Point3(100, 2, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 1, 100), Point3(93, 2, 101), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(97, 1, 100), Point3(100, 2, 101), Terrain.DIRT_ROAD))
  --House second stage
  r3:add_cube(Cube3(Point3(90, 2, 90), Point3(91, 3, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 2, 90), Point3(100, 3, 91), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(99, 2, 91), Point3(100, 3, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 2, 100), Point3(93, 3, 101), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(97, 2, 100), Point3(100, 3, 101), Terrain.DIRT_ROAD))
  --House third stage
  r3:add_cube(Cube3(Point3(90, 3, 90), Point3(91, 4, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 3, 90), Point3(100, 4, 91), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(99, 3, 91), Point3(100, 4, 96), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(99, 3, 99), Point3(100, 4, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 3, 100), Point3(93, 4, 101), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(97, 3, 100), Point3(100, 4, 101), Terrain.DIRT_ROAD))
  --House fourth stage
  r3:add_cube(Cube3(Point3(90, 4, 90), Point3(91, 5, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 4, 90), Point3(100, 5, 91), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(99, 4, 91), Point3(100, 5, 96), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(99, 4, 99), Point3(100, 5, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 4, 100), Point3(93, 5, 101), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(97, 4, 100), Point3(100, 5, 101), Terrain.DIRT_ROAD))
  --House fifth stage
  r3:add_cube(Cube3(Point3(90, 5, 90), Point3(91, 6, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 5, 90), Point3(100, 6, 91), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(99, 5, 91), Point3(100, 6, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 5, 100), Point3(100, 6, 101), Terrain.DIRT_ROAD))
  --House sixth stage 
  r3:add_cube(Cube3(Point3(90, 6, 90), Point3(91, 7, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 6, 90), Point3(100, 7, 91), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(99, 6, 91), Point3(100, 7, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 6, 100), Point3(100, 7, 101), Terrain.DIRT_ROAD))
  --House seven stage
  r3:add_cube(Cube3(Point3(90, 7, 90), Point3(91, 8, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 7, 90), Point3(100, 8, 91), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(99, 7, 91), Point3(100, 8, 100), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 7, 100), Point3(100, 8, 101), Terrain.DIRT_ROAD))
  r3:add_cube(Cube3(Point3(90, 8, 90), Point3(100, 9, 101), Terrain.DIRT_ROAD))

The worker is on top of the “house” because it’s made of terrain cubes. All assets haven’t got y-coodrinates so that is why they are always on top of the terrain. :stuck_out_tongue: But when you place a house as a asset instead of terrain cubes the worker will be inside. Nice work @radiant


… if there are no y-coordiantes, how could you “force” a worker to enter a cave or mine some ore underground?

@voxel_pirate haven’t found them. I think they must somewhere, but i don’t know where mabye someone else has more luck finding them :slight_smile:

@Alesfatalis I am not claiming that they are there. It was more a question to you guys if you find something or if you have an idea :wink:. The “house” you’ve created could be a way how you can include “caves” in the game. Just put a bit more “mountain” around it and there we go. But what does it help you to have a nice looking cave if your settlers are always placed on top of it :disappointed:.

What I could imagine is that once you enter a cave, the “roof” is cut-off. By doing so, the “soil” on top would be removed and your worker would be placed on the ground (as there is no soil above).

@voxel_pirate I have seen some walk and following path functions where the .luac files from the idle functions are. These walk functions use x,y,z coordinates maybe the settlers can’t start in a cave but it should be possible to let them walk in. I have until now only modified the start_game.luac which initialize each asset and terrain elements and there the assets haven’t got any y-coordinates. So let us hope radiant is going to add that to the game if they haven’t done this already :wink:

You can now. And I’m sure that would help some budding modders out there (even me). Since you’ve already done it and we can share that why not save everyone else all that work? Thanks.

[quote=“voxel_pirate, post:46, topic:3540”]
So this is the first custom animation I was able to execute.[/quote]

So did you add that to the “idle effects”? Do you want to show us how you did that?

@Xavion You dropbox link is dead for the decompiled Lua.

1 Like

@Ramcat Here you go:

Here is the .ZIP file from @Xavion : Download

1 Like

For everyone who is interested. Here a small tutorial how to decompile most of the .luac files:

1. Get luadec 5.1

2. Extract it to a folder.

3. Extract from the .smod the .luac you want to decompile.

4. Open up your cmd and browse to the folder where you extracted luadec 5.1

5. To decompile enter something like this into your cmd:

6. After hitting enter the console outputs the decompiled content (marked red in my image):

7. Just copy the output to your favorite texteditor (mine is notped++) and save it as orginal_filename.luac

8. Exchange your created .luac with the original in the stonehearth.smod

Hope this helps someone. When i have forgotten something just reply to this post :wink:

Happy Modding everyone! :grin:


@Alesfatalis… I’m strongly considering changing your title to “Opener of Pandora’s Box”…

well done! :+1:


Actually I simply replaced the idle_breathe-animation with a custom one and did not try your approach to add it yet.

For sure I will share how to do it. However, to follow the description you will need the Add-On I am working on for Blender - or a similar one for another tool. If you do not have it you would need to read all the information from your animation (rotation, location, etc.) and write it manually into a file. So as long as the Add-On is not in a better shape it might not make sense to go too much into details… the progress can be followed here.

1 Like

@SteveAdamo Thanks for your kind words!

That would be an awesome title :grin:

First off I had a hunch that I confirmed, you can have the files with a .lua extension and it will still run stonehearth fine.

@Alesfatalis, There actually is a Y coordinate for them you just don’t use it for the place_item function. Here’s the relevant function.

MicroWorld.place_item = function(l_6_0, l_6_1, l_6_2, l_6_3, l_6_4)
  local entity = radiant.entities.create_entity(l_6_1)
  if l_6_4 then
  radiant.terrain.place_entity(entity, Point3(l_6_2, 1, l_6_3))
  return entity

As you can see it as far as I can tell just sets all their Y value’s to 1 which seems to imply it’s a vertical displacement from the ground then aligned with the sames coordinates used for the terrain.

Also the batch code I used for decompiling folders of luac. It assumes that you have luadec on your desktop and than it will use it to change all .luac files in the folder it is in and all subfolders and so on into decompiled .lua files while deleting the .luac files. Essentially just put it in the stonehearth folder and run it to convert .luac to .lua, note however that on the files it completely fails on a error box will pop up, just hit cancel and it will keep going.

FOR /R %%f IN (*.luac) DO (
	C:\Users\Xavion\Desktop\luadec %%f > %%f_lua
	del "%%f"
	rename "%%f_lua" *.lua

EDIT TO AVOID DOUBLE POST; Arrgh opinions over this.

From another thread.

Done. I also played around with it a bit and discovered it’s not a template system like I first suspected, or it is just in the reverse of the normal order. So my current view is that it loads the json file for the entity or whatever and then it loads the file it extends from on top of that overwriting anything different with it’s version. That means that base_human would take precedent over human which seems kind of dodgy and also makes the use of “extends” for the syntax kind of weird as it’s kind of the other way around.