(Preview) Release 4099 for Alpha 1 Release 48/Alpha 2 Release 49 now out.
RP could be described as some sort of modding framework. It works around current limitations and bugs of the game and provides mod authors with a few helpful functions to make their life easier (or in some cases, even enables modding in the first place).
I’ve already released a bunch of (simple) mods using this framework, they’re linked below.
Features
- Mods can have dependencies (and other ordering functions, i.e. “load mod X before mine” and “load mod X after mine”)
- Every RP mod can be completely independent and can be shipped as an individual smod file. This allows authors to create mods with as much RP influence as they want. For users, this means you can simply drag-and-drop files into your mods directory to enable them, and delete/rename them to get rid of them.
- Hooks, proxies and events in lua allow multiple mods to alter the same area without conflicting with each other. It’s kind of managing and avoids that mod authors need to patch functions themselves.
- Logging features for lua and JS make debugging easier (… or in JS’ case, I think even possible).
- A simple-to-use config function allows mods to allow customization without caring about loading/validating their settings.
- A custom mod loader that allows users to (de-)activate mods with a simple entry in their user_settings.json.
Installation and usage (for users)
- Download the three RP smod files here.
- Put them into your
Stonehearth/mods
directory. - Put any RP mod into
Stonehearth/mods
. - You’re good to go!
Note that mods that build upon this framework will require you to install it (or perhaps a certain version of it). The framework itself does very little on it’s own, practically nothing that you should notice - except the loading screen.
If any mod you will install uses configuration files, they will be located at Stonehearth/mods/config/
(due to current limitations). The folder and these files might not exist. If you create this directory, Stonehearth will likely complain in its log files that config is not a valid mod, should that bother you, download this manifest.json and put it into the config folder. If you have defined any setting in your user_settings.json, then it will overwrite whatever values were set in mods/config/.
After the installation, you might see a few black flashing windows whenever you start Stonehearth. That’s RP’s current way of finding mods. If you are familiar with the command line, it’s merely executing two dir
commands (one for directories, one for files).
For developers
Until I get a real documentation, here’s a few things about RP and its mods:
- Feel free to unzip any of my smod files. They’re not compiled and the lua is somewhat documented.
- Check
rp/api.lua
,rp/rp_server.lua
andrp/rp_client.lua
for the functions that RP defines. - -rp contains the most JS stuff, zzz_rp contains the loading screen.
- In order to have your mod recognized by RP, your mod needs to have a
rp
section in itsmanifest.json
. Check my mod’s manifests to get a few examples about it. The following entries inrp
are currently supported: -
server_init
: Path to the file (relative to your mod directory) that should be executed once RP requires you to initialize the server side of your mod. This setting is optional. If it is omitted, RP assumes your mod has no server side. -
client_init
: The same asserver_init
, but for the client side. -
required
: Either a string or an array of strings. This is a (list of) mod(s) that need to be loaded before your mod. Use this to make changes to other mods or depend upon them. If a dependency is not found, the mod will not be loaded.stonehearth
,radiant
andrp
will always be loaded before your mod and do not count as mods. -
requested
: Likerequired
, but less strict. You simply request a (list of) mod(s) to be present. Any present mod will be loaded prior to yours; but your mod will still be loaded even if any of them is missing. - If you decide to pack your mod into a smod file, the smod file has to be named exactly like the folder inside it (i.e. your mod folder). Otherwise, RP will not find your mod.
- RP will add two new log files, called
stonehearth_mod.log
(client) andstonehearth_mod_server.log
(server). Whenever you userp.log
,print
orio.write
(io.output
in general), it will end up there. Errors can also end up there (instead of thestonehearth.log
) and usually provide some tracebacks so you know what went wrong. -
rp.load_config
allows you to (easily) create and validate config files (for an example, see sized workers orrp/api.lua
itself). Recommended location for config files ismods/config/[your mod name].json
. - If you want to keep folders of your developed mods without having them loaded (or don’t want to load them at all, even if they are smod files), you can use
disabled_mods
inconfig/rp.json
to prevent them from loading. An example rp.json can be found here. Mods that are disabled are treated as if they would not exist, even if another mod depends upon them.
Feel free to check the RP repos and my mods repos for more up-to-date information.
Example mods
I’ll try to out-source this into comments as we go, for now have a brief overview. Also, don’t sue me on the names, I’m a programmer, not a writer. The “For developers:” section simply lists what could be of interest to a developer (because it’s using a feature of RP, or has adapted something very common, or something like that) and can be skipped if you aren’t going to develop stuff yourself.
- Sized People: Randomly re-sizes your workers at the beginning to create a bit of variation.
- Test World: Instead of generating a huge world, it’s just generating a simple tile (about 1/25th of the normal size). Loads extremely fast and should work on weaker computers too, but you might end up on a tile without any resources.
- Workforce: Allows you to spawn more workers using the camp standard.
- Silence: Disables game music in both the menu and the game.
- Lucky Worker: More of a joke mod. The first worker will always be a man, the others will be women. Might hurt productivity a bit.
- Merge Names: More of a proof-of-concept, this will always use two first names and two last names and combine them, to get names like “Jessdara Brightwellburlyhands”.
- Spawn Stuff: My own implementation of an item spawner, as previously done by @BFHDD. It’s reading all mods’ manifests and tries to decide which entity should be spawnable (and which entity should not). Also, adds a fancy new start menu button and allows you to place stuff in 15° angles by holding [Shift].
- Alternate Naming: As proposed/requested by @phoriist, this simply changes the name generator to be able to “glue together” a name from various word snippets. With the example json, it’s also able to add gimmick prefixes and postfixes, such as titles.
- Time Is Money: Skips the intro screen, auto-selects the banner/stockpile and closes the third step automatically. It makes starting the game so much easier.
- Developers Dreams: Enforces a small map (although size can be configured in the config) and immediately places a banner and a stockpile. Combined with rp_time_is_money, this allows you to start the game and be ready within ten seconds or less.
- Hotfix: Introduces “fixes” to the camera by allowing you to change the default WASDQE keybindings to something else and enables the old drag-to-move as well as moving by touching the side of your screen. Fully configurable.
- Click and Gone: Adds a new button (Harvest, default hotkey ‘H’) that allows you to mass-chop trees and mass-harvest berry bushes by simply clicking on them.
- DIY Trees: Adds a growable component that can be used to have stuff “growing”. The default example would be oak tree saplings, which produce (slowly) growing oak trees. Also contains some half-finished code for a renewable_resource_node that adds entities instead of swapping models. @Miturion uses rp_diy_trees it for his wheat if I’m not mistaken.
- Console: Adds a console that allows execution of JS, lua (on server and client) as well as script-defined commands (for example, “select_entity”, “set_pos”, “set_model”, “set_scale”, …). Developed with a lot of help from @Xavion.
Troubleshooting, terms and conditions
RP, including all mods that I have created and linked in this thread are released under the MIT License (except those parts that I did not create, such as table.show
or partially rewritten Radiant functions). The next part should be common sense, but better safe than sorry: I kindly ask you to not re-upload any of my content anywhere else. Installing it should be easy enough, so just link to this thread. No hot linking please - the location of the files will likely change. You are however (as stated by the license) free to build your own mods based on mine and release them, as long as you give proper credit (a link to this thread and mentioning in the code completely suffices).
As mods are very experimental (and I had to work around quite a few things) keep in mind that using mods can produce bugs that are not present in the normal version. (Just like it’s possible that mods are fixing stuff, too (I’m looking at you once again, personality_serivce
). Don’t report bugs with mods to anyone but the mod authors. Or me, maybe it’s my fault. For all I know, the framework could have quite a few bugs.
Now that we’ve done the ugly part, let’s get to the “May I take your hat, Sir” part.
If you are asking yourself why there’s a few black boxes popping up and immediately disappearing when you are starting Stonehearth now, that’s RP’s way of finding your mods. Currently, there is no other way to do that, so I’m kind of resorting to good ol’ dir
. This is not dangerous nor a malfunction, this is the intended function.
If you run into an issue while using this mod (and that issue wasn’t there before), chances are I’ve messed up. RP redirects its output to a new log file, called “stonehearth_mod.log” (client) or “stonehearth_mod_server.log” (server). If you think there’s something wrong with RP or any of these mods, please provide an accurate description and attach the logs (upload them to pastebin/codepad/somewhere similar). This means: stonehearth.log
+ stonehearth_mod.log
+ stonehearth_mod_server.log
. The latter two should be in the same directory as your stonehearth.log
.
Third party mods using RP
As long as this list is still small and cute, I’ll be able to maintain it.
Outdated:
- r1402: Item Spawner by BFHDD
Spotlights
Give me a shout and I’ll add yours.
Outdated but somewhat accurate:
- r2300: Stonehearth Gameplay - Alpha 1 (r27) - Modded Edition by @Petard, not exactly accurate
- r2200: Stonehearth Alpha One - Mod Test: Spawn Items by @tkh
- r1400: Stonehearth Mod Spotlight - Alpha 1 - RepeatPan’s Modpack by @Petard