Adds semi-realistic crafting with unlockable recipes to Minetest, and removes the craft grid.
Created by rubenwardy.
License: LGPLv2.1+
rubenwardy (CC BY-SA 3.0): craftingslot*.png
Neuromancer (CC BY-SA 3.0): craftingfurnace*.png
BlockMen (CC BY-SA 3.0): gui_*.png
paramat (CC BY-SA 3.0) creative_trash_icon.png (derived from a texture by kilbith, same license)
Any recipes must be designed such that any particular item can only be used as one of the ingredients.
For example, you can't have the following recipe as default:wood
could
be used twice: default:wood, group:wood
.
crafting.register_type(name)
type
used when searching for recipescrafting.register_recipe(def)
def
a table with the following fields:
type
- one of the registered types.output
- the result of the craft, eg: default:stone 3
.items
- A list of ingredients, eg: {"stone", "wood 3"}
.level
- level of station required.always_known
- If true, this recipe will never need to be unlocked.crafting.get_recipe(id)
crafting.get_unlocked(name)
name
is the player's namecrafting.unlock(name, v)
name
is the player's namev
is a single output or list of outputscrafting.get_all_for_player(player, type, level)
items
- a key-value table, key being item name and value being a table:
have
- how many the player hasneed
- how many of this item neededrecipe
- the recipecraftable
- is craftable? craftable
is a table of the items the player can craft with the items they have.uncraftable
is a table of items the player knows about, but is missing items for.crafting.get_all(type, level, item_hash, unlocked)
item_hash
- a table with keys being item names or group names (eg: group:wood
)
and the value being the number required.unlocked
- a list of outputs the player has unlocked.crafting.set_item_hashes_from_list(inv, listname, item_hash)
crafting.find_required_items(inv, listname, recipe)
crafting.has_required_items(inv, listname, recipe)
"main"
list in inv
contains the required items.crafting.perform_craft(name, inv, listname, outlistname, recipe)
listname
and put output in the outlistname
list in inv
.crafting.make_result_selector(player, type, level, size, context)
type
- craft type.size
- how many slots to show on a page.context
- server-side storage between show and submit, can be {}
.
crafting_page
- page to showcrafting.result_select_on_receive_results(player, type, level, context, fields)
crafting.make_on_rightclick(type, level, inv_size)
crafting.create_async_station(name, type, level, def_inactive, def_active)
Installation:
# Dependencies for linter and test framework
sudo apt install luarocks
sudo luarocks install luacheck
sudo luarocks install busted
# Set up git hook to disallow commiting when linter or tests fail
./utils/setup.sh