Taking Questions about Mixintos and Overrides

We don’t need a stable mod loading order, we need a customisable one - see RP. I think I’ve covered pretty much all possible cases in a quite solid system.

Appending to lists could become a bit weird though. There’s a few ways this issue could be tackled:

  • Introducing keywords for keys, such as append(key), which adds elements to the existing list, remove(key), which removes elements from the list - we could probably go on. Personally, I think sort(key, callback_handler_name) might be useful too, as would be insert(key, after_value) (or insertBefore/insertAfter/insertAt).
  • Using more magic. For example, recipe jsons could be identified by an ID instead of being an array. So [ { "category" : "Weapons" }, { "category" : "Tools" }] could become { "tools" : { "category" : "Tools" }, "weapons" : { "category" : "Weapons" } }. However, this comes at a price because (I believe) the order is not guaranteed with objects. So you would have to introduce a priority field there (which in this case would be the best approach I think) and then have lua deal with it (if possible by providing functions to deal with that).

If we modded radiant’s json loading function to allow us access to cache or even just to check against the append/sorted/removed/whatever than we could get that working. It probably wouldn’t even be too hard, load in the file, check for mixintos, run the mixintos on the cached code, voila! Actually when thinking about it how does lua handle mutability? If I make an object or array called x and then do y = x is y a copy of x or a reference to x? Because if it’s a reference than you wouldn’t even to mod radiant as we’d already have the cached object. I can’t really think of a use case for much of those either, what were you thinking?

I’m not really sure what you mean by your second point, it seems confusing and I’m not really sure how it works. It seems to be some way of turning arrays of objects into objects (of arrays? Your json is broken horribly), that just seems kind of odd to me for appending to a list.

EDIT:
I forgot that you’d have to cleanup the json from the objects caused by keys named things like “append(model_variants)” which would be created.

lua tables are always references. I really think that we can’t change it however. The whole loading business - which includes mixins and mixintos - is likely handled by the engine in C++.

insertBefore, insertAfter and companions might seem useless right now - but if we are already messing around with this stuff, we might as well provide some proper functionality that covers future cases too. The idea would be to cover all possible useful cases, not the ones we need right now. In the case of recipes, it’s useful to keep ordering intact - perhaps I want something in-between weapons and construction?

Give me a break, I just forgot three quotes.

The second point isn’t confusing at all. Instead of using an array you simply assign each category an unique ID (which happens to be “tools” and “weapons” here, but the other would be “construction_and_fences” or something like that). However, using an object isn’t exactly favorable, it bloats the json and is contra-productive in this case - because this might work for categories, but it won’t work for recipes themselves, unless you decide to give them all ids too.


It might be possible to add this functionality to single components of the game, but not everywhere. I believe it would be possible to patch Component:extend, which would allow us to search for insert and other key commands (however, it would need to be insert(key, my_mod_name) to avoid keys overwriting each other) and then perform this magic on the json before the original extend is called.

This excludes all C components, however, including model variants.

so i have the beginnings of a tutorial going, illustrating a simple mod to add new journal entries using mixintos… however, i’m running into the “hurdle” i feared, given my system specs…

it just takes too long to edit json, load game, test… edit json, load game, test…

@RepeatPan, does your “test world” mod work with r34? this could save me a considerable amount of time, and hopefully let me finish this guide… :smile:

1 Like

RP r3399 is the preview for R34. It’s working, I believe. If you just want a tiny world, however, you can adjust the user_settings.json value that I mentioned in the other thread (mods.stonehearth.world_generation.method = "tiny").

If it takes too long, you can use rp_time_is_money + rp_developers_dreams, which shortens the game to about as much as you can while still providing some sort of usability.

To spawn stuff I’d throw in rp_spawn_stuff too.

Edit: Scrap that, this is a misunderstanding on my part. I was thinking about lua tables; mixintos can deal with Arrays. It’s just a bit… awkward. I think mixintos insert their elements at the beginning, which means that the question about the mixinto < normal < mixin order remains.

is there a way to add plain text as description to a .json file?
Text that is just there for the reader, not doing anything.

No-ish. If you’re thinking of comments (“stuff that is in the file but ignored by programs parsing it”), then the answer is no. JSON does not support comments (and it’s not doing that by design).

What you could do is defining keys that are not used by the program (such as "#_comment~" : "Blorp."). Keep in mind though that these, at the wrong locations, could cause errors - in the worst case evil, hidden ones.

Thanks, I will try that. The manifest will become a total mess when mods get large with comments. just like the game’s one.

edit: meh, does not work.

As I’ve said, it really depends on where you put it. As an alias, I would really not recommend it.

WAit, can someone explain to me what MIxintos actually means again?

Hi Guys (not sure if this is the right section…)

I’m trying to use the override function to replace the carpenter’s recipe list.

But when I try and open the workshop menu to craft an item it doesn’t open.

Below is the error code and the files I am using

error

    2014-Feb-08 16:46:16.636535 | 1 |                  renderer.entity | selected authoring entity (Entity 56 Carpenter Workbench).  Ignoring
2014-Feb-08 16:46:16.653536 | 1 |                  renderer.entity | selected authoring entity (Entity 56 Carpenter Workbench).  Ignoring
2014-Feb-08 16:46:16.849562 | 1 |                  renderer.entity | selected authoring entity (Entity 56 Carpenter Workbench).  Ignoring
2014-Feb-08 16:46:17.040585 | 1 |                  renderer.entity | selected authoring entity (Entity 56 Carpenter Workbench).  Ignoring
2014-Feb-08 16:46:17.269613 | 1 |                  renderer.entity | selected authoring entity (Entity 56 Carpenter Workbench).  Ignoring
2014-Feb-08 16:46:17.424630 | 1 |                  renderer.entity | selected authoring entity (Entity 56 Carpenter Workbench).  Ignoring
2014-Feb-08 16:46:52.232207 | 1 |                              rpc | received reply with unknown call id '434'
2014-Feb-08 16:46:52.232207 | 1 |                              rpc | received reply with unknown call id '435'
2014-Feb-08 16:46:52.232207 | 1 |                              rpc | received reply with unknown call id '436'
2014-Feb-08 16:46:52.232207 | 1 |                              rpc | received reply with unknown call id '437'
2014-Feb-08 16:46:52.232207 | 1 |                              rpc | received reply with unknown call id '438'
2014-Feb-08 16:46:52.232207 | 1 |                              rpc | received reply with unknown call id '439'
2014-Feb-08 16:46:52.232207 | 1 |                              rpc | received reply with unknown call id '440'
2014-Feb-08 16:46:52.232207 | 1 |                              rpc | received reply with unknown call id '441'
2014-Feb-08 16:46:52.232207 | 1 |                              rpc | received reply with unknown call id '442'
2014-Feb-08 16:46:52.232207 | 1 |                              rpc | received reply with unknown call id '443'
2014-Feb-08 16:46:52.232207 | 1 |                              rpc | received reply with unknown call id '444'

Manifest.json

{
	"info" : {
		"name" : "Colors"
	},
	"aliases" : {
		"purplebunny" : "file(entities/critters/purplebunny)",
		"comfy_bed_dkpurple" : "file(entities/furniture/comfy_bed/comfy_bed_dkpurple.json)",
		"comfy_bed_dkpurple_proxy" : "file(entities/furniture/comfy_bed/comfy_bed_dkpurple_proxy.json)",
		"cloth_bolt_dkpurple" : "file(entities/crafting_materials/cloth_bolt/cloth_bolt_dkpurple.json)",
		"dye_dkpurple" : "file(entities/crafting_materials/dye/dye_dkpurple.json)",
		
		"comfy_bed_dkyellow" : "file(entities/furniture/comfy_bed/comfy_bed_dkyellow.json)",
		"comfy_bed_dkyellow_proxy" : "file(entities/furniture/comfy_bed/comfy_bed_dkyellow_proxy.json)",
		"cloth_bolt_dkyellow" : "file(entities/crafting_materials/cloth_bolt/cloth_bolt_dkyellow.json)",
		"dye_dkyellow" : "file(entities/crafting_materials/dye/dye_dkyellow.json)",
		
		"mixinto:berry_bush" : "file(/mixintos/berry_basket.json)",
		"mixinto:cloth_bolt" : "file(/mixintos/cloth_bolt.json)",
		
		"override:carpenter_recipes" : "file(/overrides/carpenter_recipes.json)",
		"override:wool_png" : "file(/overrides/wool_bundle.png)",
		
		"recipe:comfy_bed_dk_purple" : "file(/recipes/comfy_bed_dk_purple.json)",
		"recipe:sheep" : "file(colors/recipes/sheep_recipe.json)"
	},
	"mixintos": {
        "stonehearth:berry_bush" : ["colors:mixinto:berry_bush"],
		"stonehearth:cloth_bolt" : ["colors:mixinto:cloth_bolt"]
	},
	"overrides": {
		"stonehearth/entities/professions/carpenter/recipes/recipes.json" : "colors:override:carpenter_recipes",
		"stonehearth/entities/cloth/wool/wool_bundle/wool_bundle.png" : "colors:override:wool_png"
    }
}

overrides/carpenter_recipe.json

{
   "craftable_recipes" : [
      {
         "category" : "Construction & Furnishings",
         "recipes" : [
            "file(picket_fence_recipe.json)",
            "file(picket_fence_gate_recipe.json)",
            "file(simple_wooden_chair_recipe.json)",
            "file(arch_backed_chair_recipe.json)",
            "file(table_for_one_recipe.json)",
            "file(dining_table_recipe.json)",
            "file(not_much_of_a_bed_recipe.json)",
            "file(comfy_bed_recipe.json)",
			"file(colors:recipe:sheep)"
         ]
      },
      {
         "category" : "Tools, Weapons & Armor",
         "recipes" : [
            "file(wooden_sword_recipe.json)",
            "file(wooden_buckler_recipe.json)"
         ]
      }
   ]
}

In the manifest file for recipe:sheep I’ve also tried “file(/colors/recipes/sheep_recipe.json)” and “file(recipes/sheep_recipe.json)”, I don’t get any “could not find” errors, but it still doesn’t work.

Before when sheep_recipe.json was in the same directory as recipes.json I had no trouble; so my current guess is that the recipe needs a relative directory, not an absolute one, but I’m not sure how to do this with lua/json or if even that’s what’s wrong.

Help me, pretty please? =3

If the carpenter fails to find a file, it will simply not open the window IIRC. Three things:

  1. Are you sure you want override and not mixinto? Override will remove all existing recipes. You should avoid that.
  2. Unless you copy over all recipe.json files too, you should use stonehearth/.../recipes/*_recipe.json instead of file(*_recipe.json) for the original recipes. I believe file is evaluated before the override happens (or rather, the override simply points to the other file).
  3. file(foo:bar) is nonsense. It’s either an alias (foo:bar) or it’s a path to a file. Not both.
1 Like

I started out with a mininto last night, but I kept getting errors, so I figured I would try override and see if it made any difference…

I can’t believe I actually used file(foo:bar), I feel incredibly stupid right now >.<;


I have now switched back to mininto and I’m only getting 1 “rpc | received reply with unknown call id” error now, (presumably the sheep)
Here is the file: mixintos/carpenter_recipe.json

{
   "craftable_recipes" : [
      {
         "category" : "Construction & Furnishings",
         "recipes" : [
			"(colors:recipe:sheep)"
         ]
      }
   ]
}

I also tried “colors:recipe:sheep”, but it doesn’t work either.

Assuming your mod folder is called “colors”, you want "colors:recipe:sheep". And that should work - try specifying the path to the json instead.

It doesn’t work :cry:

Right, after some testing I can confirm that aliases do not work. So you need to use file(). In this case, try "file(/recipes/sheep_recipe.json)". No need to put “colors” in front, unless you don’t use file. It’s either-or.

How is your manifest not complaining about that? What is your folder structure like? Can you zip it?

I might write a tool that auto-checks such aliases…

2 Likes

@Chimeforest & @RepeatPan: Hmmmm this is going to be one of the next things I was going to tinker with.

-listens intently; :smile:

2 Likes

thanks, I can see where I went wrong with mine now… will test when I get home tomorrow…

To be honest, my little setup is going well. My setup currently is

##rp_test/manifest.json

{
	"info" : { "name" : "test mod please ignore" },
	
	"aliases" : {
		"pony" : "file(entities/spawnable/pony)"
	},

	"mixintos" : {
		"stonehearth/entities/professions/carpenter/recipes/recipes.json" : "file(mixin.json)"
	}
}

##rp_test/mixin.json
{
“craftable_recipes” : [
{
“category” : “My First Pony Farm”,
“recipes” : [
“file(pony.json)”
]
}
]
}

##rp_test/pony.json

{
	 "type":"recipe",

	 "work_units"  : 3,
	 "recipe_name" : "Pony",
	 "description" : "pony pony pony pony",
	 "flavor"      : "I'm not going to ask how you can craft ponies",
	 "portrait"    : "/stonehearth/entities/furniture/table_for_one/table_for_one.png",
	 "category"    : "weapons",

	 "ingredients": [
			{
				 "material" : "wood resource",
				 "count" : 2
			}
	],
	"produces": [
			{
				 "item":"rp_test:pony"
			}
	]
}
3 Likes

It works! =D
But the sheep isn’t shearable =/ lol

Here is the zip anyway: zzzZIP

I honestly have no idea why the manifest isn’t complaining about it =/
I tired several variations and it didn’t complain about any of them.
I guess it’s just cool with it? idk >.>;

EDIT/p.s.: Is there a way to get my recipe section to appear after the vanilla ones?