Adding craftable recipes directly to assembling-machines?...

Things that we aren't going to implement
Post Reply
User avatar
Volvith
Inserter
Inserter
Posts: 40
Joined: Mon Jun 26, 2017 12:28 pm
Contact:

Adding craftable recipes directly to assembling-machines?...

Post by Volvith »

So, I've been messing around with custom assembling machines lately.
The main problem I'm having is that it is (to my limited knowledge) not possible to, without scripting workarounds, assign specific base mod recipes to assembling machines with the current system.

I've seen function scripts that temporarily make assembling machine's ingredient_count the same as the #ingredients of the recipe, and I've seen recipes be re-categorized based on allowed production per assembling machine.
The first method here is rather complex, and kind of a half-assed hacking way of achieving the desired result.
The latter method is probably nearly impossible to make compatible with mods for which it wasn't specifically modified for.

I have to say that, even though i'm not new to writing code in that i followed a 2 year course in application development, I'm now 4 days, and probably not more than 30 hours, into modding, so I'm not entirely sure how doable the following suggestion is, but...

would it be an idea, not even a good one, to add another identifier to assembling machines, not unlike ingredient count?
I'm thinking something along the lines of the code below:
{
type = "assembling-machine",
name = "assembling-machine-1",
--[[... etc.]]
crafting_categories = {
"crafting",
},
crafting_recipes = {
"assembling-machine-3",
"rocket-silo",
},
crafting_speed = 0.75,
ingredient_count = 2,
--[[... etc.]]
}
In this scenario, the crafting_recipes would have priority over both the ingredient_count's, and the crafting_categories' values, in that the recipes ignore them.

Again, I don't know how feasible an idea this is, and I know that the system works for the base game, as there's never been a need for any other method of defining the craftable recipes, but, in my opinion, defining the craftable recipes in assembling machines, or production machines in general, by just their ingredient count and category is not specific enough.

There might be better ways of handling the problem presented here than this though...
So, i suppose this is more of a suggestion than anything else.
IDK though, food for thought maybe? :3

Anyhow, thanks for reading i suppose.
If whoever is reading this has any experience with prototype modding, and has come across this issue before, i'd like to hear your solution to the problem, as i'd maybe learn a thing or two.

Cheers lads! ^^
Rational People: If it ain't fucked, don't fuck it.
Engineers: If it ain't fucked, unfuck it till it's perfect.
Me as an Engineer: If it ain't fucked, i'll fuck it till it is.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Adding craftable recipes directly to assembling-machines?...

Post by bobingabout »

Have you considered crafting category?

You can define new ones just like defining new recipes. Every recipe can be a member of only 1 crafting category, but machines can have multiple categories assigned to them.
If you want a machine to accept a specific list of recipes, you could give every recipe it's own category, then simply add these categories to the list on each machine you want to be able to craft them.

It's basically the difference between an assembling machine, furnace, chemical plant, and oil refinery, ALL of them are assembling machines, each has it's own category, or set of categories.

Furnace might be type = "furnace", but under the hood, that's just an assembling machine with a special logic assigned: Automatic recipe selection, which limits it to single ingredient recipes. You could quite easily make the chemical plant, refinery or assembling machine a furnace type, if the list of recipes on that machine all only had 1 ingredient (and every recipe on the list had it's own, so you couldn't have say, Pipe and Gear, as both take iron plates), likewise you could make an assembling machine type entity to smelt metal, you then have to set the recipe of which metal to smelt.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
Volvith
Inserter
Inserter
Posts: 40
Joined: Mon Jun 26, 2017 12:28 pm
Contact:

Re: Adding craftable recipes directly to assembling-machines?...

Post by Volvith »

bobingabout wrote:Have you considered crafting category?

You can define new ones just like defining new recipes. Every recipe can be a member of only 1 crafting category, but machines can have multiple categories assigned to them.
Yeah, but that's kind of the issue here.
If any other mod depends on the base category of a recipe, this way of doing it would make it incompatible with that mod.

Again, the current system works for nearly everything, but there's not really any way to interact with specific base recipes at the moment, which is precisely what i'm trying to achieve.

I'm not proposing a complete overhaul of the system, but a way to overwrite both the category and ingredient count for specific recipes in specific assembling machines.

Code: Select all

	data.raw.recipe ["laser-turret"]							.category			=	"automatrius-assem_two"
	data.raw["assembling-machine"]["assembling-machine-2"]		.ingredient_count	=	"12"
	data.raw["assembling-machine"]["assembling-machine-2"]		.crafting_categories	= 	{}

	table.insert(data.raw["assembling-machine"]["assembling-machine-2"]["crafting_categories"], "automatrius-assem_two")
Kind of like this, but with 3 different categories for the new assembler, assm1 and assm2.
And roughly 250 lines of code, which seems excessive to reassign 3 recipes to different assemblers... -_-

If interested, entire code-sheet is in the spoiler below.
data-updates.lua
Rational People: If it ain't fucked, don't fuck it.
Engineers: If it ain't fucked, unfuck it till it's perfect.
Me as an Engineer: If it ain't fucked, i'll fuck it till it is.

Post Reply

Return to “Won't implement”