Page 1 of 1

[Mod] Crafter [0.2] [crafter]

PostPosted: Mon Oct 22, 2012 10:01
by MasterGollum
This is an utility MOD, itself does nothing. Crafter MODE clones the crafting definition system to allow new MOD developers to create their own craft systems. For example a pottery wheel to do items with clay, a mill to produce flour from cereals, etc.

How it works?
It give you 2 functions crafter.register_craft(craft) and crafter.get_craft_result(data). The main difference with the default ones is that they are not restricted for the method name, you can use whatever name you want and create a new family of crafts. They are used exactly as the default ones are used, with the exception that register_craft requires the method property.

crafter.get_craft_result returns the original table stored, so if it has specific properties they can be accessed.

Possible crafting methods
If it works fine (normally it does :P) and it has acceptance it could be cool create new families of crafts. In this case it would be required to specify a fixed number of slots for the new craft items, in the same way all the furnaces has 1 slot as input.

For example: food (as cooking is already used), pottery, carpentry, jewelry, forge, ...

We can post here the different crafting types (aka methods).

Images:
Don't apply, it is just a couple of functions

License: WTFPL.

Depends: default

Download: https://github.com/MasterGollum/crafter/zipball/master

Releases:
Version 0.2: debugged
Version 0.1 Initial release

New crafts types

smelting
Grid 2x2
Mods using it: smelter

PostPosted: Mon Oct 22, 2012 10:32
by PilzAdam
And this is not possible with the current API?

PostPosted: Mon Oct 22, 2012 10:37
by MasterGollum
PilzAdam wrote:And this is not possible with the current API?


Maybe it is but I did not find the way :(

The register craft provided by the default is not versatile, it gives an error as I reported the last time. It's really a shame, because it is restricted only to the standard craft types and it doesn't allow to create new craft types.

PostPosted: Mon Oct 22, 2012 10:41
by PilzAdam
MasterGollum wrote:
PilzAdam wrote:And this is not possible with the current API?


Maybe it is but I did not find the way :(

The register craft provided by the default is not versatile, it gives an error as I reported the last time. It's really a shame, because it is restricted only to the standard craft types and it doesn't allow to create new craft types.

Can you rewrite your code into c++ and pull request it to the engine repo?

PostPosted: Mon Oct 22, 2012 10:49
by MasterGollum
PilzAdam wrote:
MasterGollum wrote:
PilzAdam wrote:And this is not possible with the current API?


Maybe it is but I did not find the way :(

The register craft provided by the default is not versatile, it gives an error as I reported the last time. It's really a shame, because it is restricted only to the standard craft types and it doesn't allow to create new craft types.

Can you rewrite your code into c++ and pull request it to the engine repo?


I can't, I don't know c++, neither I have development ide for do it. I think it is only remove the restriction, somewhere in the definition of this function it is validating that only known types of craft can be stored, it is remove this restriction. I feel it needlessly restricting. If an additional level of integrity want to be added it can be provide a register_craft_type function, but I don't think it is necessary.

PostPosted: Mon Oct 22, 2012 12:22
by rubenwardy
This would be usefull on my mod if i did cookers and frying pans etc... food_realcraft here we come...

PostPosted: Mon Oct 22, 2012 13:28
by MasterGollum
rubenwardy wrote:This would be usefull on my mod if i did cookers and frying pans etc... food_realcraft here we come...


Glad you like it :)

I suggest if you will use this mod, let's decide a size for the food cooker grid, so if other people wants to do more crafts they have ever the same definition and the recipes are compatible as well as the new possible cookers. For example I think for food a 2x2 grid can be fine. Unless you want to be very realistic four ingredients is enough for prepare tons of cooking recipes :) Otherwise a 3x3 grid will be needed.

My proposal is:
* craft type: food
* grid size: 2x2

PostPosted: Mon Oct 22, 2012 14:39
by Mito551
this. is. just. great. i like it very much.

PostPosted: Mon Oct 22, 2012 14:47
by MasterGollum
Mito551 wrote:this. is. just. great. i like it very much.


Thank you :) In fact I don't understand why it's not the default behavior of the functions provided for the API, the way they are done doesn't allow to extend the game without change the core API.

PostPosted: Mon Oct 22, 2012 15:13
by InfinityProject
Could you put up an example of what you could do?

PostPosted: Mon Oct 22, 2012 15:44
by MasterGollum
InfinityProject wrote:Could you put up an example of what you could do?


First you register the node as a craft, just you give it the type you want.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
  -- In the list of definitions
  crafter.register_craft({
    type = 'pottery',
      output = 'potter:awasome_jar',
      recipe = {
      {'default:clay_lump','default:clay_lump'},
      {'default:clay_lump','default:clay_lump'},
      }
  })


Second part, inside the abm function of your node you can check if a particular inventory fits with any of the crafts registered for this type. I used the same syntax than the default functions, if on day this is implemented in the core API, the only think would be done will be change the crafter prefix and all will keep working.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
  -- Inside your the abm of your crafter node
  local shape = inv:get_list("shape")
  crafter.get_craft_result({method = "pottery", width = 4, items = shape})


You can take a look to the furnace in the default mod to see how to use them in a bigger context. The difference is that is not restricted, method/type can be anything you want.

PostPosted: Mon Oct 22, 2012 15:54
by InfinityProject
Sweet man! This will add much more creativity to minetest.

PostPosted: Mon Oct 22, 2012 16:00
by MasterGollum
InfinityProject wrote:Sweet man! This will add much more creativity to minetest.


I hope so :) and also can be useful for avoid recipe conflicts. I read so many times in the Mods posts "this recipe already exists in the Mod XXX".

PostPosted: Mon Oct 29, 2012 10:42
by MasterGollum
Debugged and created the first MOD that uses it.
New craft type smelting grid 2x2,
For examples see smelter (http://minetest.net/forum/viewtopic.php?id=3546)

PostPosted: Fri Nov 15, 2013 04:13
by SegFault22
Can you make the table for crafting types Tridimensional, the third dimension being "burntime" (for fuels)? This would allow us to register fuels as crafting types, just like minetest default, as that currently is the simplest method to doing that, which does not require horrible hackwork.
Thank you for making this mod, without it I would not be able to release MoreStuff2 ahead of schedule.

PostPosted: Sun Dec 01, 2013 15:04
by D0431791
It seems that the "replace" part, just like taking the bucket back after using a lava bucket as fuel, was not implemented.

Re: [Mod] Crafter [0.2] [crafter]

PostPosted: Tue Jun 24, 2014 20:03
by golthem
Is this still working?