[Mod] Crafter [0.2] [crafter]

Post Reply
User avatar
MasterGollum
Member
Posts: 79
Joined: Thu Sep 27, 2012 14:48

[Mod] Crafter [0.2] [crafter]

by MasterGollum » Post

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
Last edited by MasterGollum on Mon Oct 29, 2012 10:40, edited 1 time in total.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

And this is not possible with the current API?
Last edited by PilzAdam on Mon Oct 22, 2012 10:32, edited 1 time in total.

User avatar
MasterGollum
Member
Posts: 79
Joined: Thu Sep 27, 2012 14:48

by MasterGollum » Post

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.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

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?

User avatar
MasterGollum
Member
Posts: 79
Joined: Thu Sep 27, 2012 14:48

by MasterGollum » Post

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.

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

This would be usefull on my mod if i did cookers and frying pans etc... food_realcraft here we come...
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
MasterGollum
Member
Posts: 79
Joined: Thu Sep 27, 2012 14:48

by MasterGollum » Post

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

User avatar
Mito551
Member
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Post

this. is. just. great. i like it very much.

User avatar
MasterGollum
Member
Posts: 79
Joined: Thu Sep 27, 2012 14:48

by MasterGollum » Post

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.

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Post

Could you put up an example of what you could do?

User avatar
MasterGollum
Member
Posts: 79
Joined: Thu Sep 27, 2012 14:48

by MasterGollum » Post

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.

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.

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.
Last edited by MasterGollum on Mon Oct 22, 2012 15:53, edited 1 time in total.

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Post

Sweet man! This will add much more creativity to minetest.

User avatar
MasterGollum
Member
Posts: 79
Joined: Thu Sep 27, 2012 14:48

by MasterGollum » Post

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".

User avatar
MasterGollum
Member
Posts: 79
Joined: Thu Sep 27, 2012 14:48

by MasterGollum » Post

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)

User avatar
SegFault22
Member
Posts: 872
Joined: Mon May 21, 2012 03:17
Location: NaN

by SegFault22 » Post

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.
"All we need it the right major crisis and the nations will accept the new world order."

D0431791
Member
Posts: 19
Joined: Wed Nov 06, 2013 11:43

by D0431791 » Post

It seems that the "replace" part, just like taking the bucket back after using a lava bucket as fuel, was not implemented.
Minetest can be better if
*better data structure for players and unstackable items like JSON
*multi sqlite files so that multi dimension can be easily implemented
*more convenient mob developing interface

golthem
Member
Posts: 43
Joined: Tue Jan 21, 2014 20:22
In-game: Golthem

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

by golthem » Post

Is this still working?

Post Reply

Who is online

Users browsing this forum: No registered users and 42 guests