Questions about the mini-map

Hey guys, I have been working on a project and i’m not sure if the following are possible, can the illustrious modders of the discourse shed some light for me?

  1. Is the pre-game mini-map accessible (art, code etc.)
  2. The basics of how it works (just to make sure I understand correctly)
  3. Is there a way to produce that mini-map not in the game, aka as a standalone picture?

Thanks :slight_smile:


I don’t have any answers for you, but I like where you’re headed with this… :smile: :+1:

1 Like

Heh heh, unfortunately i’m keeping my project secret for now, but i’ll leave it to your imagination.

1 Like

Please note I have very little experience with html/js

Path to html/js


I’m just going to go over everything I think is important, again my knowledge is limited.

embark.html is the main view for the embark screen, it sets up the html elements.

embark.js handles most of the interaction with the view, user input, calls to the lua side to get new map data, calls to map.js to redraw the map.

map.js handles most of the drawing, ie the cursor, actual map. It also provides tile colors, if you need to change those.

the .less’s are used to provide information to html elements, like position, background images, color, ect. I am very unfamiliar with less.


Where does the map data come from?

this appears to be the call that fills the map data'stonehearth:new_game', 12, 8, seed, self.options)
     .done(function(e) {
        self._map_info = e.map_info
     .fail(function(e) {
        console.error('new_game failed:', e)

stonehearth:new_game un-aliases to a call in stonehearth\call_handlers\new_game_call_handler.luac

Function you should look for
function NewGameCallHandler:new_game(session,response,num_tiles_x,num_tiles_y,seed,options)

This function actually is the return, if you’re concerned with how the data is populated.

function NewGameCallHandler:_get_overview_map(tile_margin)

As you move the cursor around, data about vegetation and wildlife is populated on the side of the view, this is done through this function.

_updateScroll: function(cell) {

Example call

 var map = $('#map').stonehearthMap('getMap');

Default map re-roll button action

self.$("#regenerateButton").click(function() {'radiant:play_sound', {'track' : 'stonehearth:sounds:ui:start_menu:reroll'} );

     self._newGame(function(e) {'radiant:play_sound', {'track' : 'stonehearth:sounds:ui:start_menu:paper_menu'} );

Generates a new map through our _newGame call, dicussed above, then sets map data by acessing the map element and calling setMap with our map data.

To start the game

_embark: function(cellX, cellY) {
  var self = this;'radiant:play_sound',
                       {'track' : 'stonehearth:sounds:ui:start_menu:embark'} );'stonehearth:generate_start_location', cellX, cellY, self._map_info);

stonehearth:generate_start_location un-aliases to a call in stonehearth\call_handlers\new_game_call_handler.luac

function NewGameCallHandler:generate_start_location(session,response,feature_cell_x,feature_cell_y,map_info)

If you need me to expand upon how world generation works I will glad to look over it, as of now haven’t had the need too.


Everything here is basically straight forward. If you have specific questions let us know.


Again these are both relatively straight forward. If you have specific questions let us know.

Could you elaborate more, I guessing you are looking to have a picture replace what the canvas is drawing from the generated map.
Again, not being versed in html/js I can’t advise the best solution, but I’d do something like this.

inside embark.less

#map {
  position: absolute;
  background: url('./images/mybackground.png'); -ADD THIS
  top: 129px;
  left: 65px;

I am unsure, you may have to specify width, and height. If this gives you trouble you can always override the default background image.


with your own image.

From here replace, in map.js

_drawMap: function(context) {
  var self = this;

  var grid = self.options.mapGrid;
      for (var y = 0; y < grid.length; y++) {
         for (var x = 0; x < grid[y].length; x++) {
            self._drawCell(context, x, y, grid[y][x]);


 _drawMap: function(context) {

That should remove any drawing that is done, other than the cursor that you move around with the mouse.

Just keep in mind the generated map data is a requirement for generating the world.

Please let me know if I got anything wrong, I’ll be glad to revisit this, again I am guessing. If you more questions let us know. :wink:


Thanks very much for the informative reply @honestabelink

Sorry I was not clear enough, what I want to do is print the randomly generated map to a different program say photoshop or paint. I hope that explains it better if not i’ll edit in more explanations.


So you want to get the canvas context and render that to say a .png. Does this have to be done programmatically, I mean wouldn’t it be easier to just printscreen, and then paste into say photoshop where you could crop the image or do whatever you need to do.

I wouldn’t think Stonehearth would allow to access the disk to write a file, I’ll check into it, just give me a few minutes.

1 Like

It doesn’t necessarily need to be done through programming however if you understood my goal you would realize how much work it would save for me.

I got something working, let me know if it’s an okay enough workflow. Please note this is a very hacky solution.

  1. open up Stonehearth
  2. click new game
  3. click re-roll map, I can create a separate button, I just used it cause it was there.

Stonehearth opens a new window containing an image of the map.

Finally, drag and drop to save.

If this is good enough let me know, perhaps I can make it more automatic, but I’m unsure. I wouldn’t minding check around again. :wink:


wow @honestabelink … I am truly impressed with how you have thrown yourself into the coding mix and contributed so much (so quickly) to the rest of the community…

here, have +5 internet points on me… :wink: :+1:


Thank you very much @honestabelink, this is what I needed. Anyway can you send me the script or tell me how to do it?

Like a normal Stonehearth mod place it in your mods folder.

Click the “Re-Roll” button on the “Embark” scene to get started.

From here a new window will pop-up, from this window drag and drop the image out of the window.

To get another map click anywhere in the new window. This will generate a new map, and re-fill the new window.

Clicking the “Re-Roll” button again to generated another map will not work anymore, also closing the new window will close Stonehearth.


The update to r188 has broken part of this. I’ll see what I can do to resolve it, as of now you’d have to restart Stonehearth after each map re-roll.

@TurtleSquish - I re-uploaded a new version for r188.

1 Like

When I tried it for r188 the game freezes on a black screen for a few minutes before crashing
Any thoughts?

I don’t think opening windows is exactly what the game supports or expects, so I wouldn’t use that way. The whole thing is a sandbox and while there are ways to write to the disk, they are not supported and should not be used.

I suppose the best way to do it right now (although I’m not a hundred percent certain about its possibility) would be to create a saved object and store the data within, then read said object in an external program. I guess that’s the “official” way.

Everything is fine on my end. I just ran it with no problems. There however seems to be changes to some of the files in r188 that I missed. Perhaps one of them is the cause. I’ll re-upload it in a few minutes. :wink:

Is it your intention this is to be used by just you, or is this part of your mod. If it is I’d advise against doing it this way also as @RepeatPan mentioned.

I like my hacky solution but this is a bit far out there and not something the end user should be putting up with. My thought process was that this was going to be used just by you.

I have no intention of putting it anywhere but on my game, and for my own private use. But thank you for clarifying.

I updated it again for r188…

I had Steam validate my files, it showed I had one file out of date. Perhaps this was somehow the cause. I don’t really no how, but maybe.

Let me know if this version works, otherwise I’ll re-upload again now that my files should be good. :wink:

If it still does not work I’ll look into alternatives to the problem, perhaps we could come up with another solution.

Yeah that did it, it is fixed thank you very much I hope I’ll be able to release the product soon. But I cannot promise, I’ve been directing a low budget film, and we’re in post-production so that keeps me pretty busy.

1 Like