RP and RepeatPan's mods

(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)

  1. Download the three RP smod files here.
  2. Put them into your Stonehearth/mods directory.
  3. Put any RP mod into Stonehearth/mods.
  4. 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 and rp/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 its manifest.json. Check my mod’s manifests to get a few examples about it. The following entries in rp 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 as server_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 and rp will always be loaded before your mod and do not count as mods.
  • requested: Like required, 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) and stonehearth_mod_server.log (server). Whenever you use rp.log, print or io.write (io.output in general), it will end up there. Errors can also end up there (instead of the stonehearth.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 or rp/api.lua itself). Recommended location for config files is mods/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 in config/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:

Spotlights

Give me a shout and I’ll add yours.

Outdated but somewhat accurate:

9 Likes

Sized People

True to its name, this mod will simply re-size any worker to a random size. By default, men will be scaled between 100% and 110%, while women will be scaled between 90% and 100%. In addition to that, it will also modify the speed at which they can run (at normalSpeed / size rate - i.e. if you double someone’s size, they’ll run only at half speed). For those not that well with maths, it simply means that giants are slower, while small workers are much faster. This only affects walking speed, sadly. I’d love to have this affect chopping speed (but the other way around).

This can be changed by you using a config file. An example is available here. Just put it into your mods/config folder (might needs to be created). The syntax is as followed:

  • Each key contains min and max, which is the size relative to the normal one (1.0 being normally grown, 2 would be twice as tall).
  • There are two fallback keys, male and female. These are used if there is no key designed for this entity/model.
  • You can define a key per model (format [gender]_[index], currently gender would be either “male” or “female”, with index being 1, 2 or 3). In the example config, I’ve scaled female_1 to 120%-130% of her normal size. Feel free to add, remove and modify these keys as you please.

For developers: This mod features post-creation hooks (i.e. functions that are called after an entity has been created, rp.add_entity_created_hook) to re-size the workers. This can be used to do all sorts of stuff. It’s also one of the few mods using RP’s config feature at the moment. Also, some merry “Let’s mess around with components”.

4 Likes

Test World

Using a “test” blueprint instead of the normal generated one, this is a very small map (1/25th of the normal one, I believe). It loads extremely fast but you might end up on a tile without any mountains. I would only recommend this to other mod authors that need to re-start their game quite often.

For developers: Not much interesting as we simply rewire a function inside the world generator. The most interesting thing is the use of rp.load_stonehearth_service, which allows us to get access to WorldGenerator that is not included inside Stonehearth’s API.

2 Likes

Workforce


The modification that started this whole thing. It’s adding an action to your camp standard (blue banner thingy). Clicking on it will spawn a new worker somewhere close. The game gets a bit laggy the more workers are there, and sometimes crashes when spawning new ones - so use it with caution.

For developers: How to add new commands to existing entities using rp.add_entity_created_hook. Involves all the basic JS and lua required to get it working.

3 Likes

Silence

Hello darkness, my old friend
I’ve come to talk with you again
Because a vision softly creeping
Left its seed while I was sleeping
And the vision that was planted in my brain
Still remains
Within the sound of
RADIANT ENTERTAINMENT PRESENTS
GEOMANCER BUNNY MENU ALPHA RELEASE

I’ve seen the request to turn off music for quite some time and believe me, when you start the game thirty times in an hour, the intro really gets on your nerves. So here we are: A mod that disables music. All kind of music, including ambient. It’s not the cleanest solution, but since I cannot exactly check if there’s a stop_music function it’s the best I can do.

For developers: How to mess around with JS, intercepting radiant.call functions using rp.add_call_proxy (I need to rename this function at some point to rp.set_call_proxy) and adding own files to a manifest, I guess.

2 Likes

Lucky Worker

More of a joke than anything else, inspired by this thread I’ve decided to put it into a quick mod. The first worker spawned will always be male, any worker spawned after that will be female. This is, of course, usable with and without sized workers.

This mod does not add anything to spawn workers. If you wish to have more little minions, take a look at Workforce above.

For developers: How to mess around with a faction by overloading a simple function (in this case, faction:create_new_citizen).

2 Likes

Merge Names

Inspired by this thread I’ve written it as a little proof-of-concept. It’s replacing the default name generator for the default faction (whose name I simply cannot remember) with one that doubles the name. This means that instead of having [First Name] [Last Name], workers will have [First Name][first Name] [Last Name][last Name] names. This leads to results such as “Viodara Carlwinebaub”, “Jessdara Brightwellburlyhands”, “Scarlettabi Nonacbaub” and “Abielena Baubboltoose”. Depending on the name, it overflows the GUI a little.

For developers. Not too much interesting going on here, it’s again replacing a faction’s function, this time faction:generate_random_name.

2 Likes

i think it goes without saying, but seeing as i blather on in virtually any thread, i’ll go ahead and say it…

this is all sorts of awesome… thanks for taking the time to put all this together,and give others in the modding community another great springboard to aid in their own efforts… well done! :+1:

5 Likes

I agree with Steve, this is brilliant. Too bad I’m at work… will have to wait for several hours to try this!! I am so impressed to see this already in the Alpha, I was not expecting that! But don’t take that as an insult, it was just another compliment :blush:

This is like minecraft forge, let’s hope there is no bukkit. Lol

RP has been updated to r1400. I’ve decided to implement a proper naming scheme (basically, [alpha release version][build number], with odd builds representing incomplete development/git versions).

Changelog for r1400:

  • A few changes that were lost when transitioning to the new repos; mostly concerning JS (that nobody seems to use yet).
  • Fixed print()'s tab bug.
  • [JS] rp.dump() now properly recognizes references and links to them
  • ^^^^^^^^^ now formats strings in escaped, quoted format (to indicate the type of the field a bit better)
  • radiant.callv instead of radiant.call and hacks makes life much easier.
  • Make sure we’re logging after we have been initialized.
  • Now using load_manifest instead of load_json.
  • Allow empty calls to print()/log() to insert a newline
  • Re-wrote most of the mod loading:
  • Now using fancy enums for loading status/source! They’re accessible from within the (new) rp.constants table.
  • The list of mods is saved into rp.available_mods. A mod has the following attributes: name, source, status, manifest.
  • Introduced new status for mods, “skipped”: Mods that are not RP mods or have been disabled are labeled as “skipped”. They still show up in rp.available_mods but will not be loaded and do not count as valid rp mod.
  • Improved logging by using more useful messages and adding a few more.

Also introducing a new mod:


Spawn Stuff

Inspired by BFHDD’s version, I’ve decided to sit down and try one myself. This tries to “guess” which entities are spawnable by using a whitelist and some heuristics, i.e. it has no fixed “list” anymore. Abused is again the good ol’ camp standard, which will likely be changed to the firepit or an own entity.

Like I’ve said, this version is reading all mod’s manifests to see if they add “fitting” entities (mostly by folder name). If they are, they’re added to the list. If they have a proper name and/or a proper icon, that’s taken care off too. It’s an early release and I plan to move this out of lua and into JS/HTML at some point in the future; but for now it (hopefully) suffices. There aren’t that many entities that can be spawned.

Excluded are currently especially workbenches and anything related to professions; workbenches require special magic to make them work that really isn’t worth it right now (read: I haven’t investigated enough for that yet).

For developers: Uses the fancy, new in r1400 introduced rp.available_mods to get a list of all manifests/mods to check for entities. Other than that, it’s “How to create a command and then modify it enough so the original JSON file is worth little to nothing” and a bit of entity JSON.

3 Likes

truly impressive work @RepeatPan!

curious, are you a developer by trade? apologies if this has been stated elsewhere …

1 Like

You just updated your mods and I just published my vid with your mods :smiley:

I hope your changes don’t make the video pointless as I don’t understand anything you said in your update log xD

2 Likes

I too made a mod test (spotlight) video, I used the RP Loader and the Item Spawner though. Now, just a few minutes before finishing the upload, I noticed your update with the “Spawn Stuff” mod :smile: I will keep the video though, I post a link to it later on just for your info. There will be more mod testing though!

Changes in RP will rarely affect other mods. Since you don’t know what RP is, imagine it as some sort of foundation. If you’re familiar with Minecraft modding, RP is some sort of Forge or Bukkit. It allows other modders to build mods more easily.

Another thing - silence should kill the game music completely, not just in the title screen. For example, I didn’t notice that the crate at the beginning makes a bumping sound over the music. It’s a cute little detail.

I can understand that you’re offering a zip for convenience but especially at this early stage where I could change any mod literally at any time I’m not exactly a fan of it. I mean, in the end it means you would have to update it :stuck_out_tongue:


Heh, I wish I was. I was studying computer science, but it didn’t work out. I’ve just started programming at quite a young age (I think I was about 12) and since then went through quite a few different languages, programs, frameworks, games, that kind of stuff. Right now I just have lots of free time with little better to do, so why not make the world a better place.

For Stonehearth itself it comes in handy that I’ve spent quite some time developing things for GMod, where I’ve mainly modified other people’s stuff too (basically, the same thing I’m doing now - working around existing functions, fixing bugs, reverse engineer whatever is in my way :D) and have written a few entities (that are even doing quite well on the workshop), gamemodes and fun scripts on my own. I’ve never really done something bigger in JavaScript though, especially not with this fancy new stuff (which explains why RP is kind of lacking a lot in that aspect - well that and debugging JS without proper tools (that seem to be inaccessible right now) is a pain). I’ll catch up on that though, hopefully.

2 Likes

I’m actually using the mods to test the associated website annotations on youtube, I won’t be using them anymore as it will take too much time to keep updating all of them :stuck_out_tongue:

Silence kills the title music only for me, dunno why but thats how I prefer it actually so its not a problem!

And I’m afraid I’m not familiar with the modding thing, Minecraft got too big by the time I started showing interest in it so I got scared off xD
Hopefully I shall learn all of it with the help of Stonehearth since I plan to make frequent videos, my biggest hope is that the steam release will bring enough people both to the site and my channel so I can give more time to the community (cause time is money and more views=more money)

in my expert-oh-so-humble opinion, tearing apart existing code, and putting your own spin on it is one of the best ways to not only learn a new system, but programming in general…

again, well done my friend… :+1:

1 Like

Hm, could you perhaps upload your Stonehearth.log/Stonehearth_mod_server.log (should both be in the .exe directory)? It sounds like something odd. Perhaps your version of RP is too old - I’ve renamed that function recently-ish. Also, on that note, the zip you’re linking to in your description is lacking rp itself, which means that none of the mods will work :wink:

I wholeheartedly agree. I can’t really get into something new with just reading documentations and tutorials. I’ve learned lua back then in about a week or two simply because I wanted to change the behaviour of some gamemode (client sided). It was an interesting experience and if I look back at the code I wrote back then… oh boy. Once you have the concepts of programming, however, all languages are about the same. They differ a bit in syntax and some in the calories they have but in the end, it boils down to the very same abstract stuff.

2 Likes

www.petardia.com/stonehearth/stonehearth.log
www.petardia.com/stonehearth/stonehearth_mod.log

There you go, I also added the rp.smod to the rar, should be good now! Thanks :stuck_out_tongue:

Well, something with your AI’s broken but that’s not my fault (I hope?). Can you check your stonehearth_mod_server.log if it says anything about JS errors?