Epic/mods/simplecrafting_lib
Nathan Salapat 39804b4cb6 Removed a bunch of deprecated depends.txt and description.txt files. 2022-07-06 21:10:24 -05:00
..
locale initial upload 2020-06-14 18:29:10 -05:00
saveload initial upload 2020-06-14 18:29:10 -05:00
sounds initial upload 2020-06-14 18:29:10 -05:00
templates Small updates, mostly to furniture 2021-11-26 14:37:26 -06:00
textures initial upload 2020-06-14 18:29:10 -05:00
README.md initial upload 2020-06-14 18:29:10 -05:00
api.md initial upload 2020-06-14 18:29:10 -05:00
craft.lua Removed deprecated code. 2021-09-21 08:53:45 -05:00
init.lua Added more stone carving stuff. 2020-10-24 10:44:25 -05:00
intllib.lua initial upload 2020-06-14 18:29:10 -05:00
inventory.lua Added more stone carving stuff. 2020-10-24 10:44:25 -05:00
legacy.lua Added more stone carving stuff. 2020-10-24 10:44:25 -05:00
license.txt initial upload 2020-06-14 18:29:10 -05:00
mod.conf Removed a bunch of deprecated depends.txt and description.txt files. 2022-07-06 21:10:24 -05:00
postprocessing.lua initial upload 2020-06-14 18:29:10 -05:00
register.lua initial upload 2020-06-14 18:29:10 -05:00
settingtypes.txt initial upload 2020-06-14 18:29:10 -05:00
util.lua initial upload 2020-06-14 18:29:10 -05:00

README.md

This mod adds a new crafting system, either in parallel to the default grid-based crafting system or as complete replacement to it. The new crafting system doesn't care about the arrangement of raw materials, only the relative proportions of them. Effectively, every recipe is now "shapeless".

By default, this mod has no effect on its own - it's intended as an API that allows it to be used by other mods, for example creating specialized crafting tables with particular lists of recipes available. However, if you set the "simplecrafting_lib_override_default_player_crafting" configuration variable to "true" it will replace the player's inventory crafting interface with one derived from this system.

You can continue to use minetest.register_craft to register crafts as normal, this mod hooks into it and can reinterpret recipes registered via it to use with the new crafting system as well.

Alternately, use the "simplecrafting_lib.register" method to register recipes for the new system exclusively. Examples are given below:

simplecrafting_lib.register("table", {
	input = {
		["group:stone"] = 1,
		["bucket:lava_bucket"] = 1,
	},
	output = "default:obsidian 2",

	-- Items which the crafting recipe produces, but is not
	-- formally used to make.
	returns = {
		["bucket:bucket"] = 1,
	},
})

simplecrafting_lib.register("furnace", {
	input = {
		["farming:flour"] = 1,
		["simplecrafting_lib:heat"] = 5,
	},
	output = "farming:bread",
})

simplecrafting_lib.register("fuel", {
	-- Group names are allowed when defining fuel inputs.
	-- If there is not an item specific recipe then it will take the
	-- definition of its longest burning group
	input = {
		["group:tree"] = 1,
	},
	output = "simplecrafting_lib:heat 40",
})

As a simple example, the following code will register a filter that imports all "normal" crafting recipes into a craft_type called "table", and removes them from the legacy crafting system in the process, but leaves "cooking" and "fuel" recipes alone:

simplecrafting_lib.register_recipe_import_filter(function(legacy_recipe)
	if legacy_recipe.input["simplecrafting_lib:heat"] then
		return nil, false
	elseif legacy_recipe.output and legacy_recipe.output:get_name() == "simplecrafting_lib:heat" then
		return nil, false
	else
		return "table", true
	end
end)

Note that clearing large numbers of recipes from the native crafting system can take a long time on startup, see issue #5790 on Minetest.

To create a standard crafting table that would be able to make use of the "table" craft_type populated by the above recipe import filter, there's a convenience function that provides pre-generated functions for use with a crafting table node definition. The following code shows an example:

local table_functions = simplecrafting_lib.generate_table_functions("table", show_guides, alphabetize_items)

local table_def = {
	description = S("Crafting Table"),
	drawtype = "normal",
	tiles = {"crafting.table_top.png", "default_chest_top.png",
		"crafting.table_front.png", "crafting.table_front.png",
		"crafting.table_side.png", "crafting.table_side.png"},
	sounds = default.node_sound_wood_defaults(),
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = {oddly_breakable_by_hand = 1, choppy=3},
}
for k, v in pairs(table_functions) do
	table_def[k] = v
end

minetest.register_node("crafting:table", table_def)

This produces a crafting table with a formspec similar to the following:

Crafting table formspec

See api.md for more information about how to use this mod's API.

This library is released under the MIT license.