Crafting Recipes

Post Reply
User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Crafting Recipes

by runs » Post

I'm shocked, The Samz uses a 2x2 crafter grid. And with the default one, 3x3, I never realized that the recipes were shaped with respect to the ingredients, not with respect to the grid. That is:

"item1", ""
"", ""

performs the same crafting as:

"", "item1"
"", ""

and that

"", ""
"", "item1"

etc.

I would like it to be shaped with respect to the grid itself.

User avatar
cx384
Member
Posts: 654
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Crafting Recipes

by cx384 » Post

Why don't you just implement a crafting system by yourself. To me it is outrageous that the default crafting system is still hard coded in C++ and there is no standard api to register other crafting types besides normal, cooking and fuel. Instead mods do implement their own function like technic does it with grinding and alloying.
Can your read this?

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Crafting Recipes

by runs » Post

cx384 wrote:
Tue Dec 06, 2022 12:48
Why don't you just implement a crafting system by yourself. To me it is outrageous that the default crafting system is still hard coded in C++ and there is no standard api to register other crafting types besides normal, cooking and fuel. Instead mods do implement their own function like technic does it with grinding and alloying.
I did for my old brewing mod. Maybe I will do for The Samz. Maybe for specific mechanics, maybe for default crafting system.

The problem is:

1) My time is limited.
2) Minetest is an engine, isn't it. So basic functions should be provided as it.
3) C is faster than lua, and search and match thru listings is time expensive.

User avatar
cx384
Member
Posts: 654
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Crafting Recipes

by cx384 » Post

runs wrote:
Tue Dec 06, 2022 13:05
...
3) C is faster than lua, and search and match thru listings is time expensive.
It is not that time expensive for a fixed 3x3 grid.
For n crafting recipes a simple (not optimised) algorithms would take O(n*9). (For shapeless about O(n*45))
However with optimizations it may only take logarithmic time.
Can your read this?

User avatar
LMD
Member
Posts: 1397
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: Crafting Recipes

by LMD » Post

cx384 wrote:
Tue Dec 06, 2022 13:50
runs wrote:
Tue Dec 06, 2022 13:05
...
3) C is faster than lua, and search and match thru listings is time expensive.
It is not that time expensive for a fixed 3x3 grid.
For n crafting recipes a simple (not optimised) algorithms would take O(n*9). (For shapeless about O(n*45))
However with optimizations it may only take logarithmic time.
As long as groups aren't involved, you can just hash the m*m grid and look for it in a table of hashed grids. This gives you O(m*m), which will in practice be very performant (as m is rather small).

As soon as groups and shapeless crafts get involved, it gets tricky though.
My stuff: Projects - Mods - Website

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Crafting Recipes

by runs » Post

I've investigated further and Minecraft has the same crafting system.

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests