Modding Samples

As time is going on, I’m finding myself with a few modding examples sitting around. Most of which are small projects I’ve done with other people here on discourse. My idea here is to present those simple mods all in one place.

Modding Stonehearth can be just data driven. This means even if not a programmer you will still be able to add content to the game. I would love to see more creators :slight_smile:

I’ll be contacting people I’ve worked with to get the ok to release samples containing their content here.

I will be adding more samples over time.

Please note the purpose of this is not to take away from the modders I’ve worked with. I will not be adding new features, bug fixing, or updating any of the projects below. This is merely a hub for modding samples. The intent is merely educational. Though feel free to give any a try. :wink:

Note to load any of these either extract the files to your Stonehearth ‘mods’ folder, or rename the downloaded file

$(mod_name).smod

example

Downloaded
autosave.zip

Renamed
autosave.smod

I have done some considering and I think I can manage to maintain a few simple mods. This would include simple things like adding new crops, new items, ect. Mainly short examples focusing on just one task.

Samples [2083]


Startup Script [r2083]

Use this instead

This is a start-up mod I use when developing mods. I use it to cut down on testing times. For example, with this installed you will not longer see the main menu, instead stonehearth will immediate start loading a new world on start-up, and that would is tiny, which also helps with start-up times. It also does some misc stuff.

  • lua/js code examples
  • main menu skip
  • create hearthlings
  • promote hearthlings to class
  • have hearthling place workbench
  • create stockpiles
  • place entity helper

Download - startupscript.zip - Google Drive

Add this to your user_settings.json,

"mods" : {
	"stonehearth" : {
		"world_generation" : {
			"method" : "tiny"
		}
	}
}

Don’t forget to add a comma, depending on where you insert this :wink:


When I have some free time I’ll add some more… :wink:

Archived [Old Releases - May still work/Learning Resource]


Auto Save [r188]

Creates a shared save between all games that will be saved to every 5 mins. Also quick save hot key “Tab”.

  • lua/js code examples
  • event listening
  • realtime timers
  • creating saves

Download - autosave.zip - Google Drive

Original Post - Autosave mod help


Custom Class [r188]

Adds the “Better Carpenter” to Stonehearth. He does everything just like the normal Carpenter… just better… whatever that means ;).

  • lua/js code examples
  • Adding a new class
  • Adding recipes to carpenter
  • Adding entities

Requires Jelly - Download
Download - customclass .zip - Google Drive

Original Post - Tutorial for adding new class


Embark Map Extractor [r188]

Allows you to extract the embarks screens map by click the ‘Re-roll Map’ button, then dragging and drop the image out of a new window thats openes up. Click the new window again to ‘Re-roll’ the map. Clicking the normal ‘Re-roll Map’ button will not work.

  • js code examples
  • HTML canvas example

Download - embark_map_extractor.zip - Google Drive

Original Post - Questions about the mini-map


Renewable Resource [r188]

Adds harvestable bee hive, basically a berry bush example, which can be harvested to get edible honey.

  • Adding recipes to carpenter
  • Adding entities
  • Renewable resource example
  • Food example

Download - beehivemod.zip - Google Drive

Original Post - Question: How do you add objects to r188?


Custom Critters [r188]

Adds 2 new small animals to the game which are harvestable by the “Trapper”.

  • Adding entities
  • Scenario’s (spawning in the animals)

Download - r188addingcritters.smod - Google Drive

Original Post - BATTLEPUS! and Heimerdingers Qubicle Creations


13 Likes

Thank you so much for this! I’ve been trying to get into modding stonehearth, but I haven’t been able to find any good tutorials on it, I think it’ll help a lot to look at some real, basic code.

1 Like

This is a bad example:

  • Overwriting lua files is officially advised against. Unlike most of the stuff which is “Use on your own risk”, this is actually discouraged, there’s no guarantee that it works (up to the point that it shouldn’t I believe). For people with extracted directories that use .lua as file extension, your override won’t work.
  • Overwriting lua files in general is not advised against, because as soon as two mods try to do it, well, bad things happens. This is why I try to get a “common ground” with jelly.
  • Questionable whether it’s good or bad: It’s diverging a lot from the “original flow” of the game. For example, I don’t think you’re overwriting the seed properly, which means that there is a chance that your spawn location is right in a cliff/on top of a mountain and I’m not sure how well the game handles this.

In my case, I’ve written a JavaScript which simulates clicking on the “Quickstart” button, followed by (not yet implemented) a simple “place banner here; place stockpile there”. This way, I don’t have to adapt my code when changes to NewGameCallHandler occur.

2 Likes

Again @RepeatPan all good advice.

I’ve thought about the “QuickStart” button as well, just never got around to implementing using it. As I’ve said I’ll being updating the startup script going forward. Other than that it’s a development tool, not meant for the end user.

Your advice is looking like a great solution, and is likely what I’d implement in the future. Thanks again for your thoughts :slight_smile: .

Perhaps this could be another addition for Jelly, perhaps a user setting could be added to identify development. Then all of the nonsense carried out, placing the banner, stockpiles, ect.

Great idea :slight_smile: , never crossed my mind. You can’t control the seed from calling the “QuickStart” button right? I guess instead the best solution would be just to do the calls to radiant to start loading the world yourself.

1 Like

It would be a separate mod, similar to what I’ve had for RP back then (part one and part two).

Probably calling an own call handler could work, but then again world generation is something where jelly could hook into too. RP had various options for this, which were very annoying to maintain, but offered a great deal of flexibility.

In the end, I think I would opt in for a call handler that calls the quickstart call handler with a fixed seed.

1 Like

It’s basically your mod anyway honestabelink, I just made the models and made a mess in the files. :laughing:

Of course you can include it.

I’m just updating the models, I’ve also created the honey_serving model and everything is working fine. I will upload the rar to Dropbox and you can either link that or reap it.

If someone was working on it, you could get Plantable tree’s with the Renewable Resources cough cough

There you go Stonehearth Beehive Mod

Hope you like the new models :stuck_out_tongue:

3 Likes

I’ve updated the “Startup Script” quite a bit.

New Features

  • skips the main menu at startup, goes right into loading a new world
  • the world loaded is very small, improves startup times greatly, couldn’t get it as small as Tom’s microworlds… :cry:
  • places the town banner for you

Other notes

  • I’ve overridden the seed for the world as @RepeatPan suggested, so the world will closely be the same each time.
  • I removed the override to the new game call handler. Should help when new versions of the game come out.
3 Likes

Wow I forgot to mention…

You will need to add this to your user_settings.json, for the startup script to work

"mods" : {
	"stonehearth" : {
		"world_generation" : {
			"method" : "tiny"
		}
	}
}

My bad it just skipped my mind.

Don’t forget to add a comma, depending on where you insert this :wink:

Startup Script has been updated to r2081. :slight_smile:

It’s got to be said r2081 seems like a great performance improvement all over. I haven’t play around too much with it but load times seem reduced by about half, and general stutter and slows downs seem less common.

Great work Radiant :slight_smile:

1 Like