Skip to content

Commit 27ce6d0

Browse files
p-ouellettesfan5
authored andcommittedDec 7, 2019
Clean up craft replacements docs
1 parent 103d9c5 commit 27ce6d0

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed
 

Diff for: ‎doc/lua_api.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -4782,8 +4782,9 @@ Item handling
47824782
`{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
47834783
* `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
47844784
* `output.time` = a number, if unsuccessful: `0`
4785-
* `output.replacements` = list of `ItemStack`s that couldn't be placed in
4786-
`decremented_input.items`
4785+
* `output.replacements` = List of replacement `ItemStack`s that couldn't be
4786+
placed in `decremented_input.items`. Replacements can be placed in
4787+
`decremented_input` if the stack of the replaced item has a count of 1.
47874788
* `decremented_input` = like `input`
47884789
* `minetest.get_craft_recipe(output)`: returns input
47894790
* returns last registered recipe for output item (node)

Diff for: ‎src/craftdef.h

+13-4
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ struct CraftOutput
113113
Example: If ("bucket:bucket_water", "bucket:bucket_empty") is a
114114
replacement pair, the crafting input slot that contained a water
115115
bucket will contain an empty bucket after crafting.
116-
117-
Note: replacements only work correctly when stack_max of the item
118-
to be replaced is 1. It is up to the mod writer to ensure this.
119116
*/
120117
struct CraftReplacements
121118
{
@@ -410,10 +407,22 @@ class ICraftDefManager
410407
ICraftDefManager() = default;
411408
virtual ~ICraftDefManager() = default;
412409

413-
// The main crafting function
410+
/**
411+
* The main crafting function.
412+
*
413+
* @param input The input grid.
414+
* @param output CraftOutput where the result is placed.
415+
* @param output_replacements A vector of ItemStacks where replacements are
416+
* placed if they cannot be placed in the input. Replacements can be placed
417+
* in the input if the stack of the replaced item has a count of 1.
418+
* @param decrementInput If true, consume or replace input items.
419+
* @param gamedef
420+
* @return true if a result was found, otherwise false.
421+
*/
414422
virtual bool getCraftResult(CraftInput &input, CraftOutput &output,
415423
std::vector<ItemStack> &output_replacements,
416424
bool decrementInput, IGameDef *gamedef) const=0;
425+
417426
virtual std::vector<CraftDefinition*> getCraftRecipes(CraftOutput &output,
418427
IGameDef *gamedef, unsigned limit=0) const=0;
419428

Diff for: ‎src/inventorymanager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ void ICraftAction::apply(InventoryManager *mgr,
861861
}
862862

863863
// Put the replacements in the inventory or drop them on the floor, if
864-
// the invenotry is full
864+
// the inventory is full
865865
for (auto &output_replacement : output_replacements) {
866866
if (list_main)
867867
output_replacement = list_main->addItem(output_replacement);

0 commit comments

Comments
 (0)
Please sign in to comment.