Dyes and paint Mod

Hey everyone!

I recently picked up Stonehearth and I’m very much enjoying its cute style and the ability to build anything you want. One thing I found missing was the lack of colours for tapestries, carpets, etc. though, and so I bravely embarked (with google in my hands) on the journey of my first mod.

It is still VERY barebones, just a few extra throw rug colours but the plan is to add dyes, more colours to everything involving cloth, and create a whole slew of paintings and murals. Just to add some colour to the game! I like blue, but come on :wink:

I am however now (already) stuck. I have the barebones of the painter class (who will be creating the dyes, coloured thread, and paintings), and the carpenter can make the paint brushes no problem. The class is available in the jobs overview, but when the Hearthling moves in to pick up the item, I get the following error:

release-893 (x64)[M]
c++ exception: Error in CompileScript calling "colourful/jobs/painter/painter.lua": radiant/lib/util.lua:476: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
	[C]: in function 'create_controller'
	radiant/modules/commons.lua:280: in function 'create_controller'
	stonehearth/components/job/job_component.lua:320: in function 'promote_to'
	...arth/ai/actions/change_job_using_talisman_action.lua:24: in function '_trigger_cb'
	radiant/modules/effects/effect_tracks.lua:113: in function <radiant/modules/effects/effect_tracks.lua:108>
	[C]: in function 'fire'
	radiant/controllers/time_tracker_controller.lua:91: in function <radiant/controllers/time_tracker_controller.lua:91>
	[C]: in function 'xpcall'
	radiant/modules/commons.lua:67: in function 'xpcall'
	radiant/controllers/time_tracker_controller.lua:91: in function 'set_now'
	radiant/modules/gamestate.lua:11: in function 'set_now'
	radiant/server.lua:65: in function <radiant/server.lua:63>

Something is obviously going wrong with the creation of the Painter class but I cannot tell what. I used the Weaver class as a basis and a filled in painter.lua and painter_description.json exists with only weaver specific information altered to refer to painter focussed information.
What am I missing?

A second problem I’ve been running into is the text labels. All was fine and dandy while I had the descriptions and names inside the objects and recipes themselves, but they’ve decided to hate me now that I’ve made a locales json file. I get the very nice description:
instead of:
A bright red throw rug
The manifest does have a mixin for the stonehearth en.json and mine en.json. Filepaths are correct. The stonehearth editor has no problems recognising what the strings should be when I hover over the line in its interface so by now I am rather stumped.

I hope someone can help me :slight_smile: I would include my smod file but being a new user I am not yet allowed to upload attachments!

1 Like

You may consider chatting with @Hunnie since they were looking at making a very similar mod: Could I Make This Mod?

Does your Painter lua has this:

local CraftingJob = require 'stonehearth.jobs.crafting_job'

local PainterClass = class()
radiant.mixin(PainterClass, CraftingJob)

return PainterClass

And do you have a locales folder at the root of your mod, and inside it a en.json file? You don’t need to mixinto the locales, it should be detected automatically if in that folder with that file name

I will reach out to them, thank you!

My painter lua was ALMOST that. It was missing the stonehearth. in the require. Makes sense that it should’ve been there honestly, since it’s the Stonehearth jobs insert facepalm

As for the locales, yes I have it at that location inside an en.json file. I looked around a bit more yesterday and stumbled upon a tiny little thing that I didn’t know was necessary, namely setting a default_locale in the manifest. Welp.

Both the painter and the string labels work properly now (I can finally read my items!). A new problem however, is that the original throw_rug does not seem to be properly overwritten.

this is the mixintos from the manifest regarding the original throw_rug_recipe:

"stonehearth/jobs/weaver/recipes/throw_rug_recipe.json" : "file(jobs/weaver/recipes/throw_rug_blue_recipe.json)",

this is the contents of throw_rug_blue_recipe.json

"mixintypes" : {
	"recipe_name" 	: "override",
	"description" 	: "override",
	"flavor" 	: "override",
	"ingredients" 	: "override"
"recipe_name"	: "i18n(colourful:jobs.weaver.recipes.throw_rug_blue_recipe.recipe_name)",
"description"	: "i18n(colourful:jobs.weaver.recipes.throw_rug_blue_recipe.description)",
"flavor"	: "i18n(colourful:jobs.weaver.recipes.throw_rug_blue_recipe.flavor)",
"ingredients": [
	"material": "thread resource",
	"count": 3

While Stonehearth appears to recognize that it has to do something, what happens is that anything regarding the original recipe is gone. There’s no image, no value listing, no appeal nothing. But it does show the recipe name, description, flavor text and ingredients. The throw_rug_blue_recipe appears to completely overwrite the throw_rug_recipe rather than only overwrite the listed properties.

Ops, my bad, I forgot about that.

Maybe you have it listed in the overrides section of the manifest? You mentioned it is in the mixinto, but maybe you have an old copy there?

By the way, you don’t need the "recipe_name" : "override", in your mixintypes, because they should (when you get everything working fine) just replace fine. The only one that needs that is the ingredients, as it is an array it is not targetable what you want to replace, and thus need to do that mini override.

Hey no worries! You taught me something new regardless!

Nope, I have no overrides section in my manifest, that’s what is throwing me :neutral_face: This is my whole manifest right now:

    "info": {
	"name" 	    : "Colourful",
	"namespace" : "colourful",
	"version"   : 3
    "default_locale" : "en",
    "aliases" : {
        "decoration:throw_rug_red" 	: "file(entities/decoration/throw_rug_red)",
        "decoration:throw_rug_white" 	: "file(entities/decoration/throw_rug_white)",
        "decoration:throw_rug_yellow" 	: "file(entities/decoration/throw_rug_yellow)",
        "refined:dye_blue" 		: "file(entities/refined/dye_blue)",
        "refined:dye_red" 		: "file(entities/refined/dye_red)",
        "refined:dye_yellow" 		: "file(entities/refined/dye_yellow)",
        "personal_logs:promote_painter" : "file(data/personality/painter_promote.json)",
        "jobs:painter" 		: "file(jobs/painter/painter_description.json)",
        "painter:outfit"	: "file(jobs/painter/painter_outfit)",
        "painter:brush"		: "file(jobs/painter/painter_brush)",
        "painter:talisman"	: "file(jobs/painter/painter_brush/painter_brush_talisman.json)",
        "painter:workbench"	: "file(jobs/painter/painter_workbench)"
    "controllers" : {
	"class:painter"	: "file(jobs/painter/painter.lua)"
    "less" : [
    "mixintos" : {
	"stonehearth/jobs/weaver/recipes/recipes.json" 		: "file(jobs/weaver/recipes/recipes.json)",
	"stonehearth/jobs/carpenter/recipes/recipes.json" 		: "file(jobs/carpenter/recipes/recipes.json)",
	"stonehearth/jobs/weaver/recipes/throw_rug_recipe.json"     : "file(jobs/weaver/recipes/throw_rug_blue_recipe.json)",
	"stonehearth:jobs:index"					: "file(jobs/index.json)"

thank you for your help so far!

There’s also another mod that adds a painter that does basically the same (recolored versions of furniture) - but it fails my memory now… I think it’s Yangz Yings? (yes it is)

It seems to be outdated however, but you might try reaching them as well since they seen to have quite some progress on a very similar idea - so maybe it can be mutually beneficial :smiley:

In your manifest, the “less” should be inside a “ui”

Pfff, figures that someone’s already mostly done exactly what I want to make haha. Downside of hopping in here pretty late I suppose. Looking at the steam workshop, the last update was less than a month ago so I don’t think it’s outdated. I’ll see about reaching out to them. :slight_smile: Still, I’d like to get my little thingy here working properly too as it is pretty much a little practice excersize! Just got the outfits working properly for the painter, next up, custom rigging XD Somehow!

Nice catch! However, that does not seem to fix the problems with the throw rug unfortunately :frowning: hopefully I can start getting the crafting menu to work now though, now that that one has been caught!