Page 1 of 1

Suggestion: custom "crafting definition types"

Posted: Wed Nov 13, 2013 00:42
by SegFault22
Currently there are only 5 crafting definition types. One of those types can be used by a machine, and that is "cooking". However, when we want to add our own types, like "smelting" for example, we run into an issue: the 5 crafting definition types are directly defined within the Engine, and thus we can not define a machine as using, or a recipe as being, anything other than those 5 types.
This is a serious problem, and turns a simple, elegant script into horrible hackwork to tell the machine what it does, and registering recipes. I propose a solution, where crafting definition types can be created, through either of two ways:

1. Crafting Definition Types could be registered - this would require more code than the next method, but it would be possible to tell Minetest how many inputs/outputs there would be, in the registry for a type.

2. The types could be registered similarly to how Groups are. This would work nearly identical to Groups - only the recipes of a specific type, like "cooking", would work in a machine that does that type. However, there would not be any place where the type is directly registered, just like groups (whenever a new type is encountered, it is added to the table, or however groups work).

This would make it possible for modders to easily add new machines that do things that the furnace just can't/shouldn't do, without having to add several dozen lines of horrible hackwork just to accomplish the addition of a machine and its own recipes.
Thank you for your consideration.

Posted: Wed Nov 13, 2013 01:24
by mauvebic
SegFault22 wrote:However, when we want to add our own types, like "smelting [snip] and turns a simple, elegant script into horrible hackwork to tell the machine what it does
I didn't have that problem, i simply used tables (SMELTING[input] = output), and my own craft guide works just as well checking regular and custom crafts. It may actually be more work for core devs to implement this idea.

Posted: Wed Nov 13, 2013 02:18
by tinoesroho

Posted: Wed Nov 13, 2013 21:25
by SegFault22
mauvebic wrote:
SegFault22 wrote:However, when we want to add our own types, like "smelting [snip] and turns a simple, elegant script into horrible hackwork to tell the machine what it does
I didn't have that problem, i simply used tables (SMELTING[input] = output), and my own craft guide works just as well checking regular and custom crafts. It may actually be more work for core devs to implement this idea.
It is much more efficient, for the developers to do the hard work once, than many people having to implement the functionality of their own tables and usage of said tables. It will also attract those who have creative, good ideas, but are not good at programming in LUA - who will be inclined to make their own mod adding their ideal features, rather than to go suggest it to someone who has mastered LUA, who will likely steer the ideal features in a direction that the original thinker never intended.

@"TakeThat"-Guy: Even PilzAdam suggested, to the creator of that mod, that it should be added to the engine. See This Post for more information.
Others on the Minetest IRC channel agree too, that it would be a good idea (see the logs, starting Here).

Posted: Wed Nov 13, 2013 22:18
by mauvebic
I don't really see what the big challenge is, there are already plenty of mods with a ton a custom machines that produce all sorts of things. If some people can't figure it out looking at that code or the furnace code in default, then i can't picture how new craft types make their jobs any easier.

In any case, why not just use the mod tinoesroho referenced?

Posted: Thu Nov 14, 2013 04:13
by SegFault22
mauvebic wrote:I don't really see what the big challenge is, there are already plenty of mods with a ton a custom machines that produce all sorts of things. If some people can't figure it out looking at that code or the furnace code in default, then i can't picture how new craft types make their jobs any easier.

In any case, why not just use the mod tinoesroho referenced?
It's not about new craft types, it's about allowing Any conceivable type to be registered. People could literally look at, or even copy, code from the furnace to make a new machine, if the change was made. Currently, that is not possible, because when you try to use a type that doesn't exist in the Engine, it causes an error that prevents the loading of Minetest and the mods.
We could use the mod that @TakeThatGuy mentioned, but that is only a temporary fix. What would be best, would be for the developers to make the necessary changes to the engine once, rather than an undefined number of modders having to substitute said necessary changes with their own horrible hackwork or some other mod, and said changes having to occur once for every mod that needs to add its own crafting definition types.

Posted: Thu Nov 14, 2013 05:44
by Sokomine
SegFault22 wrote: [...]People could literally look at, or even copy, code from the furnace to make a new machine[...]
That sounds like a very bad idea. Copying the whole furnace code for a new machine would result in endless copies that vary minimally from each other. There ought to be some register_furnace function or something like that first.

I like the idea of having "machines" for more complex crafts (see my table saw or color machine for that), but the very idea behind these is that you don't have to remember the crafting receipe - instead, you put your materials in the machine and get the desired output out.

Posted: Thu Nov 14, 2013 05:58
by SegFault22
Sokomine wrote: That sounds like a very bad idea. Copying the whole furnace code for a new machine would result in endless copies that vary minimally from each other. There ought to be some register_furnace function or something like that first.
I meant, copying part of the code and changing the parameters to fit one's needs, just like what people do with block/item/ore registry when they don't want to learn all of LUA and the API.

Posted: Fri Nov 15, 2013 05:23
by tinoesroho
Sokomine wrote:
SegFault22 wrote: [...]People could literally look at, or even copy, code from the furnace to make a new machine[...]
That sounds like a very bad idea. Copying the whole furnace code for a new machine would result in endless copies that vary minimally from each other. There ought to be some register_furnace function or something like that first.

I like the idea of having "machines" for more complex crafts (see my table saw or color machine for that), but the very idea behind these is that you don't have to remember the crafting receipe - instead, you put your materials in the machine and get the desired output out.
Ehh. I think there's a smelting mod, and a morefurnaces mod. In the minetest_game core, there should be a framework to register furnaces. I'm against arbitrarily adding code to the engine, but adding to minetest_game? Why not?

@SegFault:
... Um. So you're saying that the mod could work? And that it should be added to minetest_game?

Posted: Fri Nov 15, 2013 05:26
by tinoesroho
Sokomine wrote: That sounds like a very bad idea. Copying the whole furnace code for a new machine would result in endless copies that vary minimally from each other. There ought to be some register_furnace function or something like that first.

I like the idea of having "machines" for more complex crafts (see my table saw or color machine for that), but the very idea behind these is that you don't have to remember the crafting receipe - instead, you put your materials in the machine and get the desired output out.
Yoohoo!

I replaced normal furnaces with an "autofurnace" for carts back in the day. Horrible, horrible, horrible. I didn't understand the code, which is why I couldn't have both. :-(

Posted: Sat Nov 16, 2013 02:35
by SegFault22
tinoesroho wrote: @SegFault:
... Um. So you're saying that the mod could work? And that it should be added to minetest_game?
No, I am saying that if someone wants to make a simple, input+fuel=output machine, they could re-purpose furnace code to achieve that, but they would have to use the cooking/fuel crafting def. types. With the proposed changes, more crafting def. types would be possible, so the user could make many different machines with many different purposes.

Posted: Sat Nov 16, 2013 06:21
by Dopium
I think what SegFault22 is trying to say is if someone were to make a blast freezer mod or something they would still have to use the cooking/fuel def.types. A blast freezer does not cook but rather does the opposite or the unit may not need a fuel type to function ect.

Posted: Sat Nov 16, 2013 17:13
by SegFault22
Dopium wrote:I think what SegFault22 is trying to say is if someone were to make a blast freezer mod or something they would still have to use the cooking/fuel def.types. A blast freezer does not cook but rather does the opposite or the unit may not need a fuel type to function ect.
Exactly. If we were able to register our own crafting definition types, that would be possible, but currently we can't, so it is not possible. In fact, the mod I am working on will someday require a cooling machine of sorts to cool items, without the use of coal or the ability to freeze copper lumps into ingots.
Tables might not work for this, because the parameters of some things (burntime for fuels, for example) don't fit into the standard tables like in the Crafter mod. Thus, using the crafter mod does Not work, nor will it work if it is moved straight to minetest_game.
Due to issues with the crafter mod not functioning properly, I had to disable loading of my mod's "machine" segment until further notice.

Posted: Sat Nov 16, 2013 17:17
by Nore
It looks like my post has disapeared, but I made something a bit earlier that allowed custom crafting definition types: viewtopic.php?id=5739. However, I don't know if it is exactly what you want, or not...

Posted: Sun Nov 17, 2013 01:12
by Wuzzy
I just wanted to say that I like the suggestion. The idea seems general enough to justify an engine change. I think the “horrible hackwork” argument is a pretty strong argument. ;-)

Posted: Sun Nov 17, 2013 05:35
by SegFault22
Wuzzy wrote:I just wanted to say that I like the suggestion. The idea seems general enough to justify an engine change. I think the “horrible hackwork” argument is a pretty strong argument. ;-)
Thank you for the support, comrade.
About horrible hackwork: Even with the use of the "Crafter" mod, it is not possible to make recipes wider than 2x2, either they will cause a crash, or will not do anything, depending on either width or height being greater than 2. With the proposed change, we would be able to define the exact shape of our recipe, and machines would work with bigger recipes.

Posted: Mon Nov 18, 2013 00:34
by Enke
We need something like this. It could open a new world of possible mods to be made. It would also give another distinguishing feature that we could call our own.