[Spoiler] Preview of the Journal (Patch r27)

You will have recognized the “Latest Journal”-entry in the character sheet of the settlers. Actually there is a bit more behind that. For each settler there is a character’s journal which is tracking the entries which have been collected in a game. Each settler arrives in the world with a first entry. Throughout the game they are gathering new entries, e.g. if one of the workers is promoted to a carpenter. As it seems there are have been plans to give players access to all entries - not only the last one - via a button called “Journal”. The result looks like the following:

So how to activate this feature?

Just two steps are required to the journal-button to your settlers:

:one: ** Adjust “…\Stonehearth\mods\stonehearth\manifest.json”**

Look for the 3 entries including the term “show_character_sheet”. Copy and paste each entry and replace the term “show_character_sheet” with “show_journal” for each of the 3 copied lines. You will have the following 3 entries at the lower part of your manifest-file.

  1. “file(ui/game/show_journal/show_journal.html)”,
  2. “file(ui/game/show_journal/show_journal.js)”,
  3. “file(ui/game/show_journal/show_journal.less)”,

Just pay attention to add them right after the “show_character_sheet”-entries to ensure that they are at the right position.

:two: ** Adjust “…\Stonehearth\mods\stonehearth\mixins\base_human\base_human.json”**

Look for the following code which defines which commands are related to a settler:

  "stonehearth:commands" : {
     "commands" : [

… and change it to the following code (just adding another command for showing the journal):

  "stonehearth:commands" : {
     "commands" : [

Actually that’s it already. You will find now an additional button with each settler which shows the related journal.



you just bumped both @RepeatPan and @Geoffers747 off the top of the k00l kidz list… congratulations!! :clap:

but seriously, this is crazy awesome… we’ve been talking about this elsewhere, and lo and behold, its been unearthed! keep trucking @voxel_pirate… you never cease to amaze and delight… :smile:

p.s. i am so stealing this to leverage some ideas for the writer’s guild mod idea… :stuck_out_tongue_closed_eyes:


That’s actually why I have started to look into the journal, to understand how far it might be similar to the chronicle-idea I have still in my mind :wink:.


Wow awesome find, this would give a nice depth to your settlers!

♫ See as I work my gypsy magic ♫

rp_blasphemy (r2701+). A simple RP mod that does what @voxel_pirate does (just using his instructions and black magic) without modifying the smod file.

Can I have my place back, please? @Geoffers747 can come back too, his support during the development was substantial.


Glad you found it! :wink: For whatever worth it is to your planning, journal is actually legacy–it’s since been replaced with the character sheet. I guess we just left the files in place when we added the alternate button. Maybe eventually we’ll have the ability in the stat sheet to look back at previous journal entries, or open the journal from there, but that’s how it stands at the moment.


Thanks for the explanation! So there will be also no use for the nice little icon… which I declare mine now :wink:. Next I have to understand how to add an own command, which would be pretty sweet for different things.


You’re most of the way there! In the spirit of academic exercise, (ie, it may change still, though I don’t foresee it changing much in the near future) let me outline the general structure. As you already discerned, each entity has a “commands” component declared in their .json file. You add commands to an entity by adding references to json files to that section.

(Aside: Tony wrote an optimization so that if a file and its parent folder have the same name, and the file type is .json, you don’t have to include the whole path, just the folder. So to get to show_character_sheet.json, all you have to do is stop at data/commands/show_character_sheet)

If you look inside the command’s .json file, you’ll see:

“type” : “command”,

“name”: “show_character_sheet”, //this is the id, used by the commands component
“tooltip”: “Character sheet”, //appears in the ui
“description” : “Show detailed information about this character’s capabilities and personality”,
“icon”: “file(show_character_sheet.png)”, //changes the icon

“action”: “fire_event”, //describes what happens when the button is pushed in the UI
“event_name” : “show_character_sheet.stonehearth”, //name of the event fired
“event_data” : {} //data you want to package up to send.

The event that is fired is caught in the javascript file associated with the event (which you added to the manifest in your step 1.) From “show_character_sheet”:

$(top).on(‘show_character_sheet.stonehearth’, function (_, e) {
//do stuff in javascript whenever the event is fired.

The variable “e” will contain the event data you passed in via the .json file. One day we’ll have documentation for how to write Stonehearth views, but you can theoretically do anything you want here from a javascript/html perspective.

And that’s commands in a nutshell, from a UI POV. Radiant TODO before it’s ready for prime time: go back and make sure it’s easy for an entity to access commands from different mods (folders that are peer to Stonehearth.)

But how do you get data generated and manipulated by JS back to the server, so your command can actually change the game world? You have to call a function from Javascript that exists on either the lua client or the lua server, probably using “radiant_call”:

radiant.call(‘name of the function you want to call’, data you want to pass );

The name of the function is either declared in C++ (starts with radiant:…) or in stonehearth’s manifest.json file. For example in:

radiant.call(‘radiant:play_sound’, ‘stonehearth:sounds:ui:carpenter_menu:confirm’ );

radiant:play_sound is a c++ function that plays a single sound, based from the location of the UI. stonehearth;sounds:ui:carpenter_menu:confirm is a sound declared in the stonehearth manifest.json.

Alternatively, this line from place_item.js calls a function declared in the stonehearth manifest.json (choose place item location) and passes it some data about the item to place:

radiant.call(‘stonehearth:choose_place_item_location’, item.entity_uri, item.full_sized_entity_uri)

The declaration of choose_place_item_location in the manifest looks like this:

     "choose_place_item_location" : {   //user-visible name
        "endpoint" : "client",                  //whether function lives in lua client or lua server
        "controller" : "file(call_handlers/place_item_call_handler.lua)"  //file that contains the function

Somewhere inside place_item_call_handler.lua, there’s a function with this signature:

function PlaceItemCallHandler:choose_place_item_location(session, response, target_entity, entity_uri)
–handles all place-item logic, including the semi-transparent ghost item
–tells the lua server to actually place the item
–updates all the game logic.

And that’s about it!


yes, of course you can… @Geoffers747? … well, thats another story… he has quite an uphill struggle to reclaim his spot…

don’t let her fool you @voxel_pirate! she’s employing typical developer diversionary tactics! you’ve unearthed something… something that should not have been made public, for whatever X-Files/Men in black reason they may cook up… keep up the struggle! continue with the revelations!! :boom:

or… take what she said at face value, and enjoy your new icon… the choice is yours… :smile:


Full disclosure: I totally borrowed that icon off the internet somewhere.

1 Like

fuller-er disclosure… they probably borrowed it as well… :smile:

still, very forthright of you… :wink:

1 Like

Yes, sure :wink:. Thanks a lot (once more) for taking the time and explaining what happens behind the scenes. I will have to digest this a bit, read it a dozen times and start playing around… so far I can show a custom icon, just the functionality is not there yet.


This was actually fully implemented in the pre-accident release. The one we were not allowed to talk about :wink:.


… actually this is a very nice example if you want to understand how to add a pop-up window to any kind of object.


for the briefest of moments, I was going to deduct style points for your choice of test text… but thankfully for you, I happen to know what the fox says… :speak_no_evil:

1 Like

What… did it say…

It reminded Steve to take his pills; he was loose in the zoo yelling at the animals again.